Post a reply

Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)


Topic review


Re: DATE variable for script to tranfer a folder from W do U

There's no "set" command in WinSCP.

You probably wanted to do somethink like:

set Stats_dd-mm-yyyy=Stats_%date:~4,2%-%date:~7,2%-%date:~10,4% /script=script.txt

option batch abort
open s -hostkey="ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
put C:\Scripts\output\%Stats_dd-mm-yyyy% /tmp/test_Stats/

DATE variable for script to tranfer a folder from W do U

Hi all,
I know this must be a stupid question, but I'm getting mad for this...
I need to daily tranfer a folder from a Windows Server to a Red Hat one.
This folder on the windows server has the naming convention of "Stats_dd-mm-yyyy".
I'm trying to create a script for automate a daily sftp between this two folder, but I'm not able to pass the "date" variable.
Here is the script i'm trying:

#Automatically abort script on errors
option batch abort
# Disable overwrite confirmations that conflict with the previous
option confirm off
set Stats_dd-mm-yyyy=Stats_%date:~4,2%-%date:~7,2%-%date:~10,4%
# Connect
open s -hostkey="ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
# Force binary mode transfer
option transfer binary
#Put file to the remote directory /tmp
put C:\Scripts\output\%Stats_dd-mm-yyyy% /tmp/test_Stats/
#Log activities
# Disconnect
# Exit WinSCP

Every time I run this I get error becouse of the "set" command, it's not recognized...
Where am I wrong?????
Thank you