Articles

FTP in Batch Script

May 19, 2010 at 09:06:38
Specs: win2003

Hi,
I want to automate the transfer of files by FTP to a remote location using a batch file. The command runs successfuly when run from the command prompt but hangs when run from a .bat file.

here's the command:
ftp -s:D:\Scripts\ftp-put.txt

The file ftp-put.txt contains the following:
open nig.usan
usrid
passwd
ascii
cd /USAN/Weblog
mput D:\Admin\Test\*.log
close
bye

Any assistance will be appreciated.

Thanks
Emem


See More: FTP in Batch Script

Report •


#1
May 19, 2010 at 09:35:03

A long shot, but before the mput, try adding the line
pro


Report •

#2
May 19, 2010 at 10:00:56

Hi R2,

I guess that's the short form of prompt.

Also, no point in 'ascii'.

I don't know what 'close' is doing but bye works for me.


=====================================
Helping others achieve escape felicity

M2


Report •

#3
May 19, 2010 at 10:19:00

Hi,
I have made the changes but it still hangs. Is there anything more I can do...?

Thanks a lot


Report •

Related Solutions

#4
May 19, 2010 at 10:20:28

Alright, where is it hanging?

Report •

#5
May 19, 2010 at 10:32:40

Hi,
I can't exactly say where it is hanging. You know it is a single ftp command line. I have piped it to a txt file but it doesn't write anything.

Can I pipe each line in the text file?

Thanks a lot


Report •

#6
May 19, 2010 at 11:13:31

Should be:
ftp -s:D:\Scripts\ftp-put.txt > d:\scripts\ftp-log.txt


Report •

#7
May 20, 2010 at 02:13:32

Hi,
The script is working now.

I kind of stumbled on the solution because I don't have full explanation for it. I made a copy of the script to test another solution from a different location and included "lcd D:\Admin\Test\" before the "mput...". I noticed it worked so I did the same changes to the script and moved to a different location and it's working.

I can now schedule this .bat file with task manager. I am grateful for your contributions.

Thanks

Emem


Report •

#8
May 20, 2010 at 02:22:42

It would help to post the script so everyone can see what works.


=====================================
Helping others achieve escape felicity

M2


Report •

#9
May 20, 2010 at 05:49:18

I doubt anyone will see the script!

Report •

#10
May 20, 2010 at 06:18:33

It's weird, I mean, you say the script hangs, but you cant see where ... where's the output gone then ?

Report •

#11
May 20, 2010 at 06:30:46

Given the added information, I'm just going to assume the script (probably though the Scheduled Task account) didn't have write access to the local directory, and Emem interpreted this as the script hanging.

Report •

#12
May 20, 2010 at 07:17:06

Hi all,
Here's the line:
ftp -s:D:\Admin\Scripts\ftp-put.txt >> D:\Admin\Script-logs\usan-ftp.log

Here's the content of "ftp-put.txt":
open nig.usan
anonymous
anonymous
ascii
cd /USAN/Weblog
lcd D:\Admin\USAN-logs
pro
mput D:\Admin\USAN-logs\*.log
bye

NB: I was not using scheduled task to run the job, I saved the command line in a .bat file and ran it. I mentioned it to say I can now use the .bat file in the task so it had nothing to do with access right.

Like I said earlier I don't have full understanding of why it wasn't running from the earlier location.

Thanks again.


Report •


Ask Question