Ftp.exe completion inside batch file

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I run ftp.exe from batch file file:

%windir%\system32\ftp.exe -v -n -s:FTP-CMD.txt

after this line I need to erase FTP-CMD.txt ( it contains password), but also I have to move the file I've sent to another local folder after FTP.exe completes.

I know there is a way to execute FTP commands without saving file on harddrive, but I still need to perform other operations upon completing ftp transfer (move file, etc..)

So what are my options? Please advise.

Thank you.
 
SergeL said:
I run ftp.exe from batch file file:

%windir%\system32\ftp.exe -v -n -s:FTP-CMD.txt

after this line I need to erase FTP-CMD.txt ( it contains password), but
also I have to move the file I've sent to another local folder after
FTP.exe completes.

I know there is a way to execute FTP commands without saving file on
harddrive, but I still need to perform other operations upon completing
ftp transfer (move file, etc..)

So what are my options? Please advise.

Unless I'm missing some meaning, then
%windir%\system32\ftp.exe -v -n -s:FTP-CMD.txt
del FTP-CMD.txt
move file-Ive-just-uploaded c:\some-other-directory

Console applications in a batch file are executed sequentially waiting for
each command to end, so the delete and the move commands will not execute
until after the ftp command finishes.
 
Hi Paul, that's what I thought as well, but when I do
del FTP-CMD.tx
move /Y Filea File

The batch file fails silently because when I check FTP site the file has NOT transfered. When I comment out commands del and move file is transfered fine. So I believe when I call FTP.EXE from batch file, it branches out it's own thread
 
I run ftp.exe from batch file file:

%windir%\system32\ftp.exe -v -n -s:FTP-CMD.txt

after this line I need to erase FTP-CMD.txt ( it contains password), but also I have to move the file I've sent to another local folder after FTP.exe completes.

I know there is a way to execute FTP commands without saving file on harddrive, but I still need to perform other operations upon completing ftp transfer (move file, etc..)

So what are my options? Please advise.

Thank you.


See tip 925 in the 'Tips & Tricks' at http://www.jsiinc.com



Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
 
Thank you Jerold for the tip. This is a neat way of scripting FTP session I will incorporate it in my batch, however Paul was correct in his resposne that FTP will execute sequentially. Silent error misled me to believe otherwise, but I was trying to send binary files in ascii mode as I have just found out, so ftp transfer works fine now...
 
SergeL said:
Hi Paul, that's what I thought as well, but when I do:
del FTP-CMD.txt
move /Y Filea FileB

The batch file fails silently because when I check FTP site the file has
NOT transfered. When I comment out commands del and move file is
transfered fine. So I believe when I call FTP.EXE from batch file, it
branches out it's own thread.

Something must be wrong in your ftp script. I use a similar technique to
backup a mailbox off a remote server.

Try manually walking through each step of your ftp script and see if the
error becomes apparent.
 
Back
Top