Posted: 2012-12-17 04:57
I currently used WinSCP Version 5.1.2 both GUI/Window Batch Script
I store a session in ini file and used it call from my batch script to do Keepuptodate features.
First Problem: I have configured Option Batch On, so that if error will skip it, my Keepuptodate commands will always monitor and running. But I want to handle If folder exists in Remote directory no need to mkdir. If fail to detect errorlevel if Option Batch are set to On. No matter which method in approaches (such as If errorlevel 1 goto error, If exist folder path do keeuptodate else mkdir only). The result always call mkdir because it cannot detect the errorlevel neither if folder exist in remote path.
Second Problem: I noticed that WinSCP GUI can open multiple sessions at 1 Winscp GUI screen, but if you are doing Keep Remote directory up to date features..It will only work at 1 session at a time. I believe it will be the same if you apply to scripting. Winscp does support up to 9 session transfer at background, is that not support for Keepuptodate features?
Posted: 2012-12-20 10:12
I include my coding and testing coding.
rem Server Login
rem Folder Settings.
rem set monitor_path=C:\tempdata\
FOR /F "usebackq tokens=2 delims==" %%a IN ("%winscp_path%pathConfig.txt") do (
rem Path to winscp.
set winscp_path=C:\Program Files (x86)\WinSCP\
rem Log File 1 or 0.
rem set filename=%date:~0,2%%date:~3,2%%date:~6,6%_FTPLogs
FOR /F "usebackq tokens=1-5 delims=," %%a IN ("%winscp_path%machineFileType.txt") do (
If exist script.tmp del script.tmp
rem echo > %filename%.txt
echo option batch on >> script.tmp
echo option confirm off >> script.tmp
echo open %session% >> script.tmp
echo option transfer binary >> script.tmp
echo dir "%ftp_path%%mfileType%" >nul 2>nul >> script.tmp
If errorlevel 1 (echo No Error) else (echo Error Found!)
rem echo mkdir "%computername%" >> script.tmp
rem echo mkdir "%ftp_path%%mfileType%/%computername%/" >> script.tmp
rem echo keepuptodate %monitor_path% "%ftp_path%%mfileType%/%computername%/" >> script.tmp
echo exit >> script.tmp
IF "%logfile%"=="1" (set filelog=/xmllog=%filename%_!M!D!Y.xml)
"%winnscp_path%WinSCP.com" /script=script.tmp %filelog% /xmlgroups
I want to write a batch scritp if Remote FTP Folder Exist, just keepuptodate, else folder does not exist mkdir first, otherwise in xml logs always shown Error Creating folder although my keepuptodate still running.
No matter errorlevel is 0 or 1, it always print Error Found!.
Location: Prague, Czechia
You can post new topics in this forum
And it's free!