Best approach for getting error information back from WinSCP

Advertisement

gjsheridan
Joined:
Posts:
2
Location:
New York, NY

Best approach for getting error information back from WinSCP

Hello, I'm new here. I have a batch file for ftp'ing files using WinSCP. It currently works, but has no error handling in it at all.

We had a situation recently where the FTP session timed out for some reason, and we didn't know until days later.

I'll post all the relevant code if that will help, but I guess I should first explain what I'm trying to do.

The following command is in the original batch file:
D:\winscp520\winscp.com /script=D:\psft\ChaseDev\ftp_chase_ach_eft_dev.txt > D:\psft\ChaseDev\ftp_chase_output.txt
The script file ftp_chase_ach_eft_dev.txt just changes to a specific local directory and does a put of two different file name patterns. Normally there is only one file in the source directory, so it is normally just uploading one file.

The output of the command above is redirected to the file ftp_chase_output.txt.

Someone was working on this before me and started to add some error handling.

What they're doing is reading the contents of the file ftp_chase_output.txt after the command above runs, and looking for the word "Authenticated" and for the words "Error code".

This might catch some errors, but I'm worried that there will be things that we'll miss. Is there any way to tell WinSCP to create a log file with a certain name if anything goes wrong, including a problem with authentication, or a timeout? And to not create any log file at all if everything succeeds? I'm not going to attempt to deal with any errors. I just want to send an email to myself if anything at all goes wrong.

The code is already written in a batch file, so I guess I'll save some time by leaving it that way, but if I can get better error handling by using another language, I'm comfortable doing that. I know C# and I've done a little bit of PowerShell programming. I know Java too, but I haven't seen that mentioned. Does WinSCP work with both Java and C#, or just C#. Just curious.

It would be nice to have lots of flexibility in error handling, but most likely I'll just add this check for any error (if that's possible) and never touch this code again. So if it's possible to do it correctly with a batch file, I guess that would be my preference. One other consideration is emailing. If that's easier from C# than from a batch file, for example, then I would lean toward C#.

If anyone has any advice on this, it would be greatly appreciated.

Thanks,
gjsheridan

Reply with quote E-mail

Advertisement

Advertisement

You can post new topics in this forum