我想保留通过FTP远程同步的本地目录。 如果我的互联网连接已经准备就绪,我可以很容易地使用WinSCP.com连接到FTP并使用以下命令使文件保持最新:
"c:\Program Files (x86)\WinSCP\WinSCP.com" /script=connect.script
我的脚本在哪里:
# 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
FTP服务器是一个正确设置的0.9.54版本的Filezilla服务器。 'myftp'参数是使用WinSCP GUIconfiguration和命名的部分。
问题是:当我失去连接(如某人从服务器机器上拔下电缆)时,WinSCP服务就会中断。
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>
我期待'keepuptodate'可以保持该部分的活动,并在120秒内重试,基于参数'reconnecttime'。 为什么没有发生?
如果会话closures,我使用Windowsbatch file和“goto”命令find了一个“窍门”,但是它很笨拙,我不知道是否有更好的解决scheme。
我正在使用WinSCP版本5.7.6。
没有更好的解决scheme。
你用goto循环的解决scheme是最简单的解决scheme,你可以得到,重新连接keepuptodate命令。
请参阅正式的WinSCP示例以重试脚本/连接尝试 。
当然,你的WinSCP脚本需要以exit命令结束,以便它自动closures。