Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

shell script to download files from remote machine using ftp

Tags:

file

shell

ftp

I have

host name      :  "ftp.flowers.com" 
username       :  "name" 
password       :  "123" 
directory path :  "/flower/rose" 

from which I have to download "red" file. the following script is not working

ftp -in ftp.flowers.com << SCRIPTEND
user name 123
binary
cd /flower/rose
mget red
SCRIPTEND
like image 890
Karunakar Avatar asked Sep 20 '13 10:09

Karunakar


3 Answers

It would be much simpler with wget:

wget ftp://name:[email protected]/flower/rose/red
like image 157
Benoit Blanchon Avatar answered Oct 17 '22 05:10

Benoit Blanchon


Hi all its already too late and you might have resolved your issue by now. But anyhow i would like to know if you have had resolved it with any other alternative method:

I've noticed minor change in this below script which you have given, well i guess it is the "/" which is you are missing after the location "cd /flower/rose"

ftp -in ftp.flowers.com << SCRIPTEND
user name 123
binary
cd /flower/rose/
mget red
SCRIPTEND
like image 40
user2629240 Avatar answered Oct 17 '22 06:10

user2629240


wget --user=name --password=123 ftp://ftp.flowers.com/flower/rose/red

To download to a different directory than the current directory:

wget --user=name --password=123 directory-prefix=/the/target/directory/ ftp://ftp.flowers.com/flower/rose/red

Then the files will be downloaded to /the/target/directory/ .

If you know the name of the file ahead of time, you can use the -O option to wget to tell it where to write the file:

wget --user=name --password=123 --output-document=/the/target/directory/red ftp://ftp.flowers.com/flower/rose/red
like image 1
hxysayhi Avatar answered Oct 17 '22 07:10

hxysayhi