Post a reply

Options
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)

Options

Topic review

martin

Re: Script for checking WinSCP Sync or Not

Yes, that's correct.
HumbleSage

Re: Script for checking WinSCP Sync or Not

Assuming this sets ERRORLEVEL to 1 then?
HumbleSage

Script for checking WinSCP Sync or Not

Hey, love this program. I need a little help with a script I have that performs a sync with a size against a local file and only performs the transfer and sends an email if a sync occurs, otherwise it should do nothing.

In my cmd file:
2batch2

winscp /ini=nul /script="C:\scripts\sync.script"

In my sync.script:
open sftp://<site> -hostkey="<key info>"
synchronize local -resumesupport=on -filemask=file.zip c:\scripts\ /
close
bye

Results:
FTP and compare files, download if different...
Searching for host...

Connecting to host...
Authenticating...
Using username "<user>".
Authenticating with pre-entered password.
Authenticated.
Starting the session...
Session started.
Active session: [1] <site>
Comparing...
Local 'c:\scripts\OlderFiles' <= Remote '/OlderFiles'
Nothing to synchronize.
Session '<site>' closed.
No session.

It executes correctly with ERRORLEVEL 0 but does WinSCP provide an exit code to compare if there was "Nothing to synchronize."? I need this so I can perform a following IF statement against it to determine to copy the file/send email/etc.. or do nothing. Help appreciated in advance. Thanks. :)