Topic "Synchronize Script - Confirmation & External Commands"

Author Message
gsidhu
[View user's profile]

Joined: 2014-06-05
Posts: 2
Hi there, I am looking to get a little help with my winscp synchronize batch script. First, I am looking to have the script output a notification, whether the script has successfully synchronized files or returned an errorlevel 1. As you can see in the screenshot provided below, I am presently not receiving a success or unsuccessful message at the end of my script.

I would like to use this as a first going, after which I would like to incorporate email confirmations. Which leads me to my second question - is it possible to output which of files have been either synchornized or do not require synchronization, and have the output sent by email? Would XML logging be the most simplistic means? Any examples anyone can provided?

Third and lastly, would be possible to execute an external command after each file has been synchronized? Ie., I would like to run an unzip command if the file have been updated, and move the files to a separate directory.

Batch:

Code:

winscp.com /script="F:\Scripts\ScriptNotificationTest.txt" /log="F:\Scripts\FTPNotificationTestLog.txt"
if errorlevel 1 goto error

echo Synchronization Successful.
goto end

:error
echo Synchronization Failed.

end:


Script:

Code:

#Automatically abort script on errors
option batch abort

#Disable overwrite confirmations that conflict with the previous
option confirm off

#Connect to ******* server using existing login credentials
open *******

#Synchronize database releases
#Synchronize Test Zip
synchronize local -criteria=time -resumesupport=on -filemask="TestZipFile.zip" "F:\*******\Databases\Stage\Test\"

#Synchronize Test Zip 2
synchronize local -criteria=time -resumesupport=on -filemask="TestZipFile2.zip" "F:\*******\Databases\Stage\Test\"




Thanks! Smile
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
gsidhu wrote:
Hi there, I am looking to get a little help with my winscp synchronize batch script. First, I am looking to have the script output a notification, whether the script has successfully synchronized files or returned an errorlevel 1. As you can see in the screenshot provided below, I am presently not receiving a success or unsuccessful message at the end of my script.

You are missing exit command at the end of your script, so it never terminates.

Quote:
I would like to use this as a first going, after which I would like to incorporate email confirmations. Which leads me to my second question - is it possible to output which of files have been either synchornized or do not require synchronization, and have the output sent by email? Would XML logging be the most simplistic means? Any examples anyone can provided?

Yes, XML logging is the way to go. Though there's no way to find files that do not need synchronization.

Quote:
Third and lastly, would be possible to execute an external command after each file has been synchronized? Ie., I would like to run an unzip command if the file have been updated, and move the files to a separate directory.

Well, parse the XML log and call the external command for each synchronized file yourself.
For such a task, using WinSCP .NET assembly (e.g. from PowerShell) might be easier. See this example for a similar task:
http://winscp.net/eng/docs/library_example_delete_after_successful_download
_________________
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