Saved Bookmarks
| 1. |
Solve : Error trap in batch file? |
|
Answer» SORRY just a DBA not a batch expert. One of our long gone programmers wrote a batch file which puts files from a client to our sftp site and then moves them to an archive folder. HOWEVER is looks like with his code if there is any issue with the SFTP site it will just archive the records EVEN if the site is down. LOOKING at this am I correct in my assumption? psftp.exe -b CMSTrans.dat -l haddix -pw test! -batch sftp.mycompanyl.com move D:\SFTPDownload\Transfers\* D:\SFTPDownload\Archived_Transfers\ You wish to know if the second line, starting "move D:\SFTP...." will be executed regardless of whether any files were downloaded or whether or not the site is down? The answer is "YES". That I understand, what I need is something in the batch file to not do this if there is an issue with the sftp siteissue ? maybe Code: [Select]ping it ? ping sftp.mycompanyl.comThat the copy to the ftp failed for any reasonyou can try chceking errorlevel Code: [Select]psftp.exe -b CMSTrans.dat -l haddix -pw test! -batch sftp.mycompanyl.com if '%errorlevel%' equ '1' echo.FAIL EDIT: or Code: [Select]psftp.exe -b CMSTrans.dat -l haddix -pw test! -batch sftp.mycompanyl.com echo %errorlevel% to chcek if app gives errorlevel |
|