Re: how to FTP in a shell

 
SOLVED
Go to solution
inactive account
Frequent Advisor

how to FTP in a shell

Hello everybody,

FTP does not allow an optional file as a script to automate ftp sessions.
Shall I install another FTP server like ProFTP or is there a solution with th HPUX FTP client ?
6 REPLIES 6
Rainer von Bongartz
Honored Contributor
Solution

Re: how to FTP in a shell


No need to install another ftp client.

What about the .netrc file ???

see man .netrc

Regards
Rainer
He's a real UNIX Man, sitting in his UNIX LAN making all his UNIX plans for nobody ...
Patrick Chim
Trusted Contributor

Re: how to FTP in a shell

Hi,

Do you mean include the ftp process in a script ?

If yes, just like the following,

ftp -n < user
cd
lcd
put
bye
EOF

Regards,
Patrick
bjs144
Occasional Advisor

Re: how to FTP in a shell

The above examples will work but I also use

(
echo "user username passwd"
echo "ftp command"
echo "ftp command"
echo "ftp command"
echo "close"
) | ftp -vni hostname > /logdir/logfile.name
RAC_1
Honored Contributor

Re: how to FTP in a shell

ftp -n hostname <user username password
cd
passive
put your_file
bye
END
There is no substitute to HARDWORK
Allan Pincus
Frequent Advisor

Re: how to FTP in a shell

I agree with everyone above with the following caveat:

I created a script that launched the ftp session, but when it was done, it would not execute any lines folling the end of the ftp session.

The only way around this seemed to be to create an ftp script, and launch that script from another script so when the ftp session was done, I could execute additional lines of code.

- Allan
A. Clay Stephenson
Acclaimed Contributor

Re: how to FTP in a shell

My feelings are that these solutions are all rather weak in that you expect everything to work. You are testing absolutely no operations for error. A far better solution is to use the Perl Net::FTP module that allows you to check the result of every operation so that nothing is assumed to work without error. Please see this thread:
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x5d6e107d277ad611abdb0090277a778c,00.html
If it ain't broke, I can fix that.