If/Else Logic in Script
Hi Guys,
I would like to take two of my scripts one step futher and need some assistance. I'll provide my examples below, but first a very quick explaination. AND, I'm extremely new to WINSCP scripting....
I wrote a batch file that runs on an internal server with winscp installed, that calls a .txt file I've written with scp code. This code connects to a server in my DMZ (ftp server), and then successfully copies a specific file from my ftp server to a different internal server. After it copies the file internally, it finally deletes the file on the ftp server. All of that works perfectly. What I'm looking to do is add an if else statement, or some sort of logic so that if it finds the specific file on the remote server (ftp server), then perform the internal copy. If it doesn't find any file, I want it to close out properly.
Script that calls WINSCP and passes my FromFTPServer Script
=========================
start "" "C:\Program Files (x86)\WinSCP\WinSCP.exe" /console /script=C:\WINSCP_Test_Scripts_12_22_13\FromFTPServer.txt
/log="C:\WINSCP_Test_Scripts_12_22_13\FromFTP.log"
#PAUSE
exit
=========================
FromFTPServerScript
=========================
open sftp://Username:password@LocalFTPServerinDMZ
cd /home/User01/incoming/
option transfer binary
lcd \\InternalServer\InternalDirectory
get INCOMINGTESTFILE.TXT INCOMINGTESTFILE.TXT
rm /home/User01/incoming/INCOMINGTESTFILE.TXT
=========================
So, I need assistance adding some logic to this so that, if INCOMINGTESTFILE.TXT exists, then copy locally and delete. AND, If INCOMINGTESTFILE.TXT doesn't exist, then exit gracefully.
Any thoughts on how I can make this happen?
Thanks in advance,
Mike
I would like to take two of my scripts one step futher and need some assistance. I'll provide my examples below, but first a very quick explaination. AND, I'm extremely new to WINSCP scripting....
I wrote a batch file that runs on an internal server with winscp installed, that calls a .txt file I've written with scp code. This code connects to a server in my DMZ (ftp server), and then successfully copies a specific file from my ftp server to a different internal server. After it copies the file internally, it finally deletes the file on the ftp server. All of that works perfectly. What I'm looking to do is add an if else statement, or some sort of logic so that if it finds the specific file on the remote server (ftp server), then perform the internal copy. If it doesn't find any file, I want it to close out properly.
Script that calls WINSCP and passes my FromFTPServer Script
=========================
start "" "C:\Program Files (x86)\WinSCP\WinSCP.exe" /console /script=C:\WINSCP_Test_Scripts_12_22_13\FromFTPServer.txt
/log="C:\WINSCP_Test_Scripts_12_22_13\FromFTP.log"
#PAUSE
exit
=========================
FromFTPServerScript
=========================
open sftp://Username:password@LocalFTPServerinDMZ
cd /home/User01/incoming/
option transfer binary
lcd \\InternalServer\InternalDirectory
get INCOMINGTESTFILE.TXT INCOMINGTESTFILE.TXT
rm /home/User01/incoming/INCOMINGTESTFILE.TXT
=========================
So, I need assistance adding some logic to this so that, if INCOMINGTESTFILE.TXT exists, then copy locally and delete. AND, If INCOMINGTESTFILE.TXT doesn't exist, then exit gracefully.
Any thoughts on how I can make this happen?
Thanks in advance,
Mike