cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with FTP

SOLVED
Go to solution
José Luis Martínez
Occasional Contributor

Problem with FTP

Hi
I have an Alpha Server with Tru64 ver. 4.0 and I want to schedule a script that let me transfer files in mode no interactive. At first a thought in the following command

ftp -s parameter_file_name

But I relialized that this option (-s)not exist in the FTP that is installed with my version of Operating System.

So my question is, Is there a way to transfer a file in mode no interactive.

Thanks in advance!
3 REPLIES
Mark Grant
Honored Contributor

Re: Problem with FTP

You can try

ftp hostname << EOF
user username
password password
etc
etc
etc
EOF

I have never used it but something like that works, I'm sure of it
Never preceed any demonstration with anything more predictive than "watch this"
Joris Denayer
Respected Contributor
Solution

Re: Problem with FTP

Here is an example that works already several years.

It is included in a script that is started via cron.

ftp -n -v ftp.domain.com <user anonymous mymailadress@hp.com
prompt
cd /the_directory_I_prefer
get the_file_I_need
bye
EOF

Of course, I modified some directories and filenames. Modify them for your particular usage.

You can also use expect scripting. This gives you much more possibilities.

Here is a very simple one, without much error recovery, except the timeout.
Beware, it is not a secure solution !!!

#!/usr/local/bin/expect --
if $argc!=1 {
send_user "Usage: ftp-exp \n"
exit
}

set file "$argv"

set timeout 15
spawn ftp ftpsite@dom.com
expect "Name"
send "A_Login_ID\r"
expect "Password:"
send "My_password\r"
expect "ftp> "
send "cd /incoming\r"
expect "ftp> "
send "binary\r"
expect "ftp> "
send "get $file\r"
send "bye\r"
expect "bye."
exit


Hope this inspires.

Joris

To err is human, but to really faul things up requires a computer
José Luis Martínez
Occasional Contributor

Re: Problem with FTP

Thanks everybody

Your suggestions were so useful, that rigth now my script is running from the cron, thanks again.

Regards!