1833323 Members
2833 Online
110051 Solutions
New Discussion

ftp script

 
SOLVED
Go to solution
musaddaq_2
Frequent Advisor

ftp script

Hi i want to make a small script for FTP.
I want to copy one file to another server.
can any one help me out.

Regards
Musaddaq
11 REPLIES 11
Adisuria Wangsadinata_1
Honored Contributor

Re: ftp script

Hi Musaddaq,

Check the url below (docID=PU94082118354
) about 'How do I use "ftp" in a shell script?' :

http://www1.itrc.hp.com/service/cki/docDisplay.do?docLocale=en_US&docId=200000065257476

Hope this can help you.

Cheers,
AW
now working, next not working ... that's unix
Chris Wilshaw
Honored Contributor
Solution

Re: ftp script

The simplest way is something like this, although having the ID and password in the script isn't very secure;



ftp -vn << EOF
user
put
EOF

All you need to do is substitute your details for the entries in place of etc.
Robert-Jan Goossens
Honored Contributor

Re: ftp script

Hi,

Simple script

ftp -n <open xxx.x.xx.xxx (change the xxx to destinastion ip)
user user_name password (change user_name and passwd)
bin
put filename
EOF

Regards,
Robert-Jan
Gopi Sekar
Honored Contributor

Re: ftp script


you can use expect scripting utility to automate ftp proces. check man expect for more information
Never Never Never Giveup
Gopi Sekar
Honored Contributor

Re: ftp script

musaddaq_2
Frequent Advisor

Re: ftp script

Thanks to everybody for the reply

I got it.

Thanks a lot.

Regards

Musaddaq
Eknath
Trusted Contributor

Re: ftp script

Hi musaddaq,

If it is just for copying a single file. Can you think of rcp/remsh...?

Cheers!!!
eknath
musaddaq_2
Frequent Advisor

Re: ftp script

Hello Eknath
I have 410 files

Regards

Musaddaq
C. Beerse_1
Regular Advisor

Re: ftp script

Peek at `wget` or `snarf` (on http://hpux.its.tudelft.nl/). THose tools are command-line based and they can do ftp too. They are more easy to use in a script.

These tools work by url-s or uri-s. For ftp they are "ftp://user:password@site.domain/path/to/file" or "ftp://user@site.domain/path/to/file" (this asks for a password) or "ftp://site.domain/path/to/file" (this uses anonymous-ftp).

`wget` is also capable of transfering entire trees.
make everything as simple as possible, not simpler (A.Einstein??)
Bejoy C Alias
Respected Contributor

Re: ftp script

U can use 'ftp -s:nav -i 21.1.1.1' where 21.1.1.1 is the ip of the server , 'nav' is a file containing all of ur commands and user logins
eg: nav file ->


...
...commands.
...
bye
Be Always Joy ......
Bill Hassell
Honored Contributor

Re: ftp script

Note: ftp -s is not part of HP's standard ftp. You'll need to use the scripted method for standard ftp. Note also that if you have all 410 files in one directory, you can use the mput command to automatically transfer all the files. This assumes that ytou every file in the directory or can specify filename masking to select the right files. Be sure to turn off the prompt for each file by first issuing the: prompt command.

As with all scripts, try the individual commands to see that they work OK. Then put them into the script.


Bill Hassell, sysadmin