Capability

Advertisement

rhnielsen
Guest

Capability

I was looking through the documentation and not sure I can accomplish what I need. I would like to ask a simple question if possible. I'm no expert on FTP or scripting, but not afraid to do the work to make it work. Before I go down that route can someone confirm that I can accomplish the following.........

I want to put a command line at the top of a batch job that confirms that the receiving FTP server is online and functioning. I'm thinking I would write a login script and if it does not work WinSCP would return some type of error code which the batch job can look for. If the error exists the batch job would exit and not try to send the data file.

Can this be done using WinSCP?

Thank you

Reply with quote

Advertisement

Pathduck
Donor
Pathduck avatar
Joined:
Posts:
83
Location:
Oslo

Hi!

'winscp.com' is the thing to use for scripting, read the docs here:
https://winscp.net/eng/docs/scripting

Open a connection and exit:
winscp.com /command "open ftp://anonymous:password@ftp.scene.org/" "exit"

Then check return code of last command:
echo %errorlevel%
0

So if it doesn't work or server is down:

winscp.com /command "open ftp://anonymous:email@domain.com@ftp.scene.org:1234/" "exit"
Connecting to ftp.scene.org:1234 ...
Connection failed.
No connection could be made because the target machine actively refused it.
Connection failed.

echo %errorlevel%
1

Reply with quote

Guest

I downloaded the program and tested it with your command and it worked perfectly! Thank you so much! I'll make a PayPal donation to the cause.

Reply with quote

Advertisement

You can post new topics in this forum