Location: Newcastle, UK
Posted: 2012-11-26 18:42
I'm trying to use the following WinSCP script which calls a script remotely and generates a tar.bz2 file which includes a date in the name, e.g. Backup-Nov-2012.tar.bz2. This part works correctly however the script does not appear to correctly interpret the special date environment variable which is in the following format: %date:~3,8%
Through the regional settings on the Windows client I have configured the date short format to show up as dd-MMM-yyyy which actually translates to for example 26-Nov-2012, so when I use %date:~3,8% I get Nov-2012.
The following is my script, if I call it on the command line I can see that it is not correctly evaluating the date variable:
option confirm off
open -timeout=18000 diesel
call /home/diesel/tmpbackup/backup.sh >/dev/null 2>&1
C:\Program Files (x86)\WinSCP>winscp.com /script=c:\foobar\backup.txt
Searching for host...
Connecting to host...
Using username "xyz".
Authenticating with pre-entered password.
Starting the session...
Reading remote directory...
Active session:  diesel
Can't get attributes of file '/home/diesel/tmpbackup/Backup-%date:~3,8%.tar.bz2'
No such file or directory.
Error code: 2
Error message from server: No such file
Request code: 7
Your help appreciated.
Location: Prague, Czechia
WinSCP supports only plain environment variables.
You can post new topics in this forum
And it's free!