Reputation: 125
I am trying to automate a call to a remote server using WinSCP which is a redundant everyday task. I want the batch file to call remote machine - provide username and password, and later check for if files exist.
So far I am able to start a WinSCP server but still the batch file does not consume username and password - it is still asking for them and/or providing an error regarding too many arguments.
chdir /d D:\Program Files\WinSCP\
winscp.com 172.18.186.39 username password
Upvotes: 1
Views: 1719
Reputation: 202292
Your syntax does not even remotely resemble WinSCP command-line syntax for scripting.
See WinSCP article on Checking file existence using scripting:
@echo off
set REMOTE_PATH=/home/user/test.txt
winscp.com /command ^
"open ftp://username:[email protected]/" ^
"stat %REMOTE_PATH%" ^
"exit"
if %ERRORLEVEL% neq 0 goto error
echo File %REMOTE_PATH% exists
rem Do something
exit /b 0
:error
echo Error or file %REMOTE_PATH% not exists
exit /b 1
The above example is for FTP protocol. You didn't tell use what protocol are you using. If not FTP, you have to change the open
command accordingly.
You can have WinSCP GUI generate the open
command for you.
Once you have the batch file ready, use Windows Scheduler to call it regularly.
Upvotes: 2