Ftp.exe completion inside batch file

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.
 
P

Paul R. Sadowski

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.
 
G

Guest

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
 
J

Jerold Schulman

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
 
G

Guest

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...
 
P

Paul R. Sadowski

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top