Variable in console script
I am by far not a scripting or code writer but I am attempting to backup multiple network devices (over 70). I have built two different files one called the
//master-batch.cmd\\
//backupscript-text.txt\\
I am attempting to get the
master-backup.cmd
and then the script.txt
for WinSCP. I am attempting to get it to backup to a drive as ipaddress.txt.timestamp
the timestamp is working correctly but the ipaddress piece is not. In the main file I want to just simply put in multiple devices and run the script. The IP address piece on the backup file I am needing to be a wildcard to change depending on the device its connected to. I have the below in the script right now.
//master-batch.cmd\\
@echo off for /F "usebackq tokens=1,2 delims==" %%i in (`wmic os get LocalDateTime /VALUE 2^>NUL`) do if '.%%i.'=='.LocalDateTime.' set LDT=%%j set STAMP=%LDT:~0,4%%LDT:~4,2%%LDT:~6,2%%LDT:~8,2%%LDT:~10,2%%LDT:~12,2% set HOST1=172.16.1.20 "C:\Program Files (x86)\WinSCP\WinSCP.com" /script=C:\Users\admin\Desktop\backupscript-test.txt /parameter scp://ubnt:ubnt@%HOST1%
option batch abort option confirm off open %1% cd /tmp option transfer binary get system.cfg "E:\backup\%HOST*%.txt.%STAMP%" close exit
%HOST*%
to be the IP address of the host its connected to from /parameters
piece. It currently saves the file as %HOSTm%.txt.20141223130100