1834355 Members
2603 Online
110066 Solutions
New Discussion

Re: Ftp and answer file

 
SOLVED
Go to solution
Wood_2
Frequent Advisor

Ftp and answer file

Hello

I would like to connect to a server with FTP.
Is it possible to use an answer file to give the parameters and the command.

If yes, can you give the right syntax.

Thank you for your help

Nicolas
7 REPLIES 7
Marcel Boogert_1
Trusted Contributor

Re: Ftp and answer file

Hi there,

Try the following:

ftp -n << EOF
open
etcetera...
...
...
...
EOF

MB.
R. Sri Ram Kishore_1
Respected Contributor

Re: Ftp and answer file

Hi Nicolas,

Try the following:
% ftp <open wherever.com
user whatever
pass password
put filename
quit
EOF

Also go through this example:
http://www.quepublishing.com/articles/article.asp?p=170517&seqNum=2

Regards,
Sri Ram
"What goes up must come down. Ask any system administrator."
Michael_356
Frequent Advisor

Re: Ftp and answer file

Or, if you really want to use a file:

ftp -v << file.ftp

content of file.ftp:
"open wherever.com
user whatever
pass password
(m)put/(m)get filename
bye"

Regards

Michael
Wood_2
Frequent Advisor

Re: Ftp and answer file

for the second example

i write

ftp << EOF
open frbpcs24
user root
pass mypasswd
dir
quit
EOF

the answer

Password:Name (frbpcs24:root):
Login incorrect.
Login failed.
Passive mode on.
Please login with USER and PASS.
Passive mode refused. Turning off passive mode.
Please login with USER and PASS.
Please login with USER and PASS.

I could not give my password

Muthukumar_5
Honored Contributor

Re: Ftp and answer file

Yes. We can do it by running run ftp in an interactive mode as,

ftp -i -n <<-EOF 2>/dev/null

user username passwd
ls
!hostname
get /tmp/testfile
bye
EOF

It will do it
Easy to suggest when don't know about the problem!
Muthukumar_5
Honored Contributor
Solution

Re: Ftp and answer file

We can do it more secure and simply with answer file as,

cat > /tmp/ftpanswerfile
user root
ls
!hostname
get cd /tmp/
put file
bye
-----
chmod 700 /tmp/ftpanswerfile

ftp -i -n
It will do it out.

Regards
Muthu

Easy to suggest when don't know about the problem!
Wood_2
Frequent Advisor

Re: Ftp and answer file

It's perfect

Thank you for your help