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

Author Message
Ghost_W
[View user's profile]

Joined: 2012-05-29
Posts: 1
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 DATE VARIABLE
set Stats_dd-mm-yyyy=Stats_%date:~4,2%-%date:~7,2%-%date:~10,4%
# Connect
open sftp://user:password@example.com -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
log="c:\scripts\log_winscp_transfer.txt"
# Disconnect
close
# Exit WinSCP
exit


Every time I run this I get error becouse of the "set" command, it's not recognized...
Where am I wrong?????
Thank you
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24993
Location: Prague, Czechia
There's no "set" command in WinSCP.

You probably wanted to do somethink like:

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

script.txt:
option batch abort
...
open sftp://user:password@example.com -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/
_________________
Martin Prikryl
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License