Link to home
Start Free TrialLog in
Avatar of DoubleStroke
DoubleStroke

asked on

PSFTP - How Do I Detect Successful Transfer from Output File?

I have a Windows batch script (attached - UFASR03_Name_302_ftpput.bat) which PSFTP's a file to a host SFTP site.  In the batch script, I reference a batch file (attached - UFASR03_Name_302_ftpput.txt) of SFTP commands and I direct the output to a text file (attached - UFASR03_Name_302_ftpput_output.txt).  I need to report back the success or failure of the transmission to the scheduling system that initiated the batch job.  

What can I use in the output file to detect a successful transmission?  The string that I use to detect a successful transmission should only appear in the output file when the transmission is successful; never should it appear if the file was not transmitted properly.

With regular FTP, I can use the following:  findstr /c:"226 Transfer" %output%
But I can't use that "226 Transfer" string with SFTP.  It doesn't appear in the output.

As you can see from the attached output file (named UFASR03_Name_302_ftpput_output.txt), there is a string as follows:  

local:JohnDoe_201008.csv => remote:/incoming/JohnDoe_201008.csv

I believe this means the file was successfully transferred.  Can I use "=> remote" as a string to reliably indicate successful transmission 100% of the time?  Will this string ever appear if there's an error?  If not, what string should I use to detect successful transmission?
Avatar of DoubleStroke
DoubleStroke

ASKER

Oops.  Here are the files.  Windows batch file is called UFASR03_Name_302_ftpput_batch.txt
UFASR03-Name-302-ftpput-batch.txt
There seems to be no way for this in PSFTP, at least no documented one.

But PSCP will also try to use the SFTP protocol if possible, and you may even force it to do so by using the -sftp switch.
Unlike PSFTP, PSCP comes with a return value for successful transfers; please check "5.2.3 Return value" here:
http://the.earth.li/~sgtatham/putty/0.60/htmldoc/Chapter5.html#pscp
ps:

Also check "5.2.2.6 -sftp, -scp force use of particular protocol" right above the section quoted in my last comment.
Torimar, I appreciate the advise but I need to use psftp.  Thank you.
ASKER CERTIFIED SOLUTION
Avatar of torimar
torimar
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial