Batch programming help - variables
Posted: 23 Apr 2013 13:16
All,
Background:
I have a batch script that has an sftp command in it that's supposed
to log in to a server and pull a file. The set of commands to be
executed on the server are consolidated in a command file and this
file is used in the sftp command as the input parameter.
Issue:
The file to be pulled has a dynamic timestamp on it that keeps changing with every new file. I calculate that timestamp in the main
script and store it in a variable. But in order to pull the correct file, I need to pass this variable to the command file so that the
actual filename on the server could be determined on run time. But the compiler fails to recognize this variable(%ts%) in the command file.
Below is the putty sftp command in the main batch script:
psftp user@server -pw "password" -batch -be -b C:\Scripts\Inbound.txt
The contents of C:\Scripts\Inbound.txt are as below:
cd test
lcd C:\data\in\
get goods_receipt.-%ts%.txt
close
quit
The above usage of %ts% needs to be fixed. Any ideas or comments would be helpful.
Thanks in advance.
Background:
I have a batch script that has an sftp command in it that's supposed
to log in to a server and pull a file. The set of commands to be
executed on the server are consolidated in a command file and this
file is used in the sftp command as the input parameter.
Issue:
The file to be pulled has a dynamic timestamp on it that keeps changing with every new file. I calculate that timestamp in the main
script and store it in a variable. But in order to pull the correct file, I need to pass this variable to the command file so that the
actual filename on the server could be determined on run time. But the compiler fails to recognize this variable(%ts%) in the command file.
Below is the putty sftp command in the main batch script:
psftp user@server -pw "password" -batch -be -b C:\Scripts\Inbound.txt
The contents of C:\Scripts\Inbound.txt are as below:
cd test
lcd C:\data\in\
get goods_receipt.-%ts%.txt
close
quit
The above usage of %ts% needs to be fixed. Any ideas or comments would be helpful.
Thanks in advance.