0

I am trying to automate multiple switch backups from the windows host, for this i have made below script

plink.exe admin@xxxx -pw *** configupload -p ftp \xxx,eccadmin,config.txt,xxx

The above script is taking backup successfully, but I want to insert date and time stamp into the config file name, say 2015-01-01-config.txt.

I have tried this:

set arg1= date/T
plink.exe admin@xxxx -pw *** configupload -p ftp \xxx,eccadmin,%arg1%config.txt,xxx

but it doesn't work. If you have a better idea, please answer.

Vesper
  • 18,599
  • 6
  • 39
  • 61

1 Answers1

0

You should write a bit more than just "assign a string to a variable". First, you really need current date in some format, this is done as displayed here, just replace the command ver for date /t. I have found that I need to use "delims= " with a space in the filter string to get the correct value in a variable. Then you do the command as normal, and then you rename config.txt to a new name.

for /f "delims= " %%a in ('date /t') do @set arg1=%%a
plink.exe admin@xxxx -pw *** configupload -p ftp \xxx,eccadmin,config.txt,xxx
ren config.txt %arg1%.config.txt

Should do.

Community
  • 1
  • 1
Vesper
  • 18,599
  • 6
  • 39
  • 61
  • if you check my script it is login to remote host by ftp. So i can't rename a config file because it is uploaded to that host. i have to rename some how before upload. – Nirjhar Jajodia Jul 23 '15 at 04:20
  • So it's *upload*, not *download*? And you need to rename the config at remote side, right?` – Vesper Jul 23 '15 at 06:42