2

I want to keep a local directory synced remotely through FTP. If my internet connection is ready, I can easily use WinSCP.com to connect to the FTP and keep files up-to-date using the command:

"c:\Program Files (x86)\WinSCP\WinSCP.com" /script=connect.script 

Where my script is:

# Connect open myftp # Change remote directory cd / # Set options option batch continue option reconnecttime 120 option confirm off # Synchronize synchronize remote # Keep Up-to-date keepuptodate -delete 

The FTP server is a Filezilla Server version 0.9.54 correctly set up. The 'myftp' parameter is a section configured and named using the WinSCP GUI.

Problem is: when I lose connection (like someone remove the cable from the server machine) the WinSCP service dies.

Connected Starting the session... Session started. Active session: [1] myftp / batch continue reconnecttime 120 reconnecttime 120 confirm off Comparing... Nothing to Synchronize. Watching for changes, press Ctrl-C to abort... Scanning '.' for subdirectories... Watching for changes in 2 directories... Lost connection. Disconnected from server Server is going offline Session 'myftp' closed. No session. winscp> 

I was expecting that the 'keepuptodate' would keep the section alive and retry during 120 seconds, based on parameter 'reconnecttime'. Why is it not happening?

I found a "trick" by using a Windows batch file and 'goto' command that keeps calling WinSCP if the session closes, but it is clumsy and I wonder if there is a better solution.

I'm using WinSCP version 5.7.6 .

1 Answer 1

0

There's no better solution.

Your solution with the goto loop is the easiest solution, you can get, to get reconnected for the keepuptodate command.

See the official WinSCP example for retrying script/connection attempt.

Of course, your WinSCP script needs to end with the exit command, so that it automatically closes.

1
  • Thank you. It is not ideal, but I'll keep this approach. It really bothers me that WinSCP can't deal with it by itself. Commented Jan 29, 2016 at 10:47

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.