LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   BASH printf and ftp (https://www.linuxquestions.org/questions/programming-9/bash-printf-and-ftp-778912/)

remirez83 12-30-2009 11:15 AM

BASH printf and ftp
 
Hey.
Does anybody know how can I forward login, password and some commands to ftp command?
I'm making a bash script that is intended to put some files on a remote server via ftp periodically.
I tried something like this:

Quote:

printf "%s\n" "login" "password" "cd some_directory;" "put some_files;" "bye;" | ftp my_remote_server;
but it just does not work.

Only:

Quote:

printf "%s\n" "login" | ftp my_remote_server;
does the job, but offcourse not whole job. This way I have to enter password and all the commands manually. That is not what I need.

Can anybody help me prepare printf command to make this work, please?

I apreciate all your answears.
Thank you in advance.
Best regards.

jlinkels 12-30-2009 11:24 AM

Use a "here" document. A few days ago this thread was active which shows how to do it.
http://www.linuxquestions.org/questi...ansfer-778515/

jlinkels

remirez83 01-03-2010 08:54 AM

Quote:

Originally Posted by jlinkels (Post 3809026)
Use a "here" document. A few days ago this thread was active which shows how to do it.
http://www.linuxquestions.org/questi...ansfer-778515/

jlinkels

Yeap. I think it will do the job. Thank you jlinkels!

schneidz 01-06-2010 10:26 AM

my first question is 'why not use scp/ ssh ?'

maybe expect can help.

remirez83 01-13-2010 12:14 PM

Quote:

Originally Posted by schneidz (Post 3816355)
my first question is 'why not use scp/ ssh ?'

maybe expect can help.

Sorry but no, expect could not help me here cause this script was meant to run on "remote" Unix box, box where I haven't got Admin rights to install any new software. SCP/SSH, yes could be good idea, but I already have choosen ftp and solved my problem after I followed jlinkels post.

bigearsbilly 01-13-2010 12:56 PM

well, if you read the documentation for ftp you'll have heard of a
.netrc file.

this enables automatic ftp.


All times are GMT -5. The time now is 11:02 AM.