Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ftp script failing on mput * 3

Status
Not open for further replies.

stfaprc

Programmer
Feb 10, 2005
216
US
I have the following script:
Code:
ftp -in <<EOF
open 123.456.com
user user password
bin
passive
prompt
mput *
bye
to transfer the following files:
dfA107TULIP1.17DC dfA108TULIP1.14E0 dfA109TULIP1.13E2 dfA109TULIP1.17DE
dfA107TULIP1.1CD7 dfA108TULIP1.15DF dfA109TULIP1.14E1 dfA109TULIP1.1CD9
dfA107TULIP1.1FD4 dfA108TULIP1.16DE dfA109TULIP1.15E0 dfA109TULIP1.1FD6
dfA108TULIP1.13E1 dfA108TULIP1.1CD8 dfA109TULIP1.16DF

When I try "sh test.sh" , the mput does not work properly:
mput dfA107TULIP1.17DC? mput dfA107TULIP1.1CD7? mput dfA107TULIP1.1FD4? mput dfA108TULIP1.13E1? mput dfA108TULIP1.14E0? mput dfA108TULIP1.15DF? mput dfA108TULIP1.16DE? mput dfA108TULIP1.1CD8? mput dfA109TULIP1.13E2? mput dfA109TULIP1.14E1? mput dfA109TULIP1.15E0? mput dfA109TULIP1.16DF? mput dfA109TULIP1.17DE? mput dfA109TULIP1.1CD9? mput dfA109TULIP1.1FD6?
yet when I do it manually, it works fine:
ftp> bin
200 Type set to I.
ftp> passive
Passive mode off.
ftp> prompt
Interactive mode off.
ftp> mput *
local: dfA107TULIP1.17DC remote: dfA107TULIP1.17DC
200 Port command successful.
150 Opening data connection for dfA107TULIP1.17DC.
226 File received ok.
102133 bytes sent in 0.011 seconds (8.7e+03 Kbytes/s)
local: dfA107TULIP1.1CD7 remote: dfA107TULIP1.1CD7
200 Port command successful.
150 Opening data connection for dfA107TULIP1.1CD7.
226 File received ok.
103535 bytes sent in 0.049 seconds (2.1e+03 Kbytes/s)
local: dfA107TULIP1.1FD4 remote: dfA107TULIP1.1FD4
200 Port command successful.
150 Opening data connection for dfA107TULIP1.1FD4.
226 File received ok.
101967 bytes sent in 0.056 seconds (1.8e+03 Kbytes/s)
...
What do I need to do to have the script upload the files with the global mput ?
 
What about this instead ?
Code:
echo '
open 123.456.com
user user password
bin
passive
prompt
mput *
bye
' | ftp -in

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
nope, no difference.
I am using "sh" , is there another shell better suited?

The "?" at the end of the filename makes me wonder if there is a newline at the end of the file (or something similiar) but there is nothing that shows up at the end of the filename with anything I use.

 
No the ?s are just a question marks (obvious innit?), mput is still prompting you to find out if you really want to transfer all those files... Your script doesn't provide any answers, so mput asks about the next file and the next...

Try it without the "prompt" toggle, as in batch mode prompt is turned off by default and you are turning it back on...


HTH,

p5wizard
 
OOps, I meant this:
Code:
echo '
open 123.456.com
user user password
bin
passive
prompt
mput *
bye
' | ftp [!]-n[/!]

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
yes! it was the interactivity .
ThankS !
 
Prompt mode is not turned off automatically in batch mode. The "[tt]-i[/tt]" on the command line turned it off. Then the "[tt]prompt[/tt]" command turned it back on.

 
oh , <duh> .
What is the emoticon for giving oneself a "dope-slap" ?
 
Hello Sir,

Thanks anyway. Your response has helped me a lot. I could have used a copy but, I didn't know how to test the availability of the file before a copy is carried out.

I would certainly be happy to learn how to do it in a script.

Thanks once again.


Felix Mwango Mutale
 
Using this below scripts you can transfer all the files present in the target folder. Instead of * symbol, you can use regular expressions to transfer specific set of files.
for Example you can use: mput dfA*

#!/bin/sh
cd <FOLDER PATH>
HOST= '<TARGET SERVER>'
USER= '<USER ID>'
PASSWD='<PWD>'

ftp -i -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
mput *
quit
END_SCRIPT
exit 0
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top