LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 12-30-2009, 11:15 AM   #1
remirez83
LQ Newbie
 
Registered: Nov 2007
Location: Bydgoszcz
Distribution: Ubuntu
Posts: 19

Rep: Reputation: 0
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.
 
Old 12-30-2009, 11:24 AM   #2
jlinkels
Senior Member
 
Registered: Oct 2003
Location: Bonaire
Distribution: Debian Lenny/Squeeze/Wheezy/Sid
Posts: 4,171

Rep: Reputation: 506Reputation: 506Reputation: 506Reputation: 506Reputation: 506Reputation: 506
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
 
1 members found this post helpful.
Old 01-03-2010, 08:54 AM   #3
remirez83
LQ Newbie
 
Registered: Nov 2007
Location: Bydgoszcz
Distribution: Ubuntu
Posts: 19

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by jlinkels View Post
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!
 
Old 01-06-2010, 10:26 AM   #4
schneidz
Senior Member
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 4,098

Rep: Reputation: 636Reputation: 636Reputation: 636Reputation: 636Reputation: 636Reputation: 636
my first question is 'why not use scp/ ssh ?'

maybe expect can help.
 
Old 01-13-2010, 12:14 PM   #5
remirez83
LQ Newbie
 
Registered: Nov 2007
Location: Bydgoszcz
Distribution: Ubuntu
Posts: 19

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by schneidz View Post
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.
 
Old 01-13-2010, 12:56 PM   #6
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,290

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

this enables automatic ftp.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
BASH - printf printing escape codes even though I have %0b defined DevonB Linux - Newbie 5 12-23-2009 01:42 PM
Read a text file and ftp files using bash w/out leaving the ftp prompt dj_tyr Linux - Newbie 6 10-12-2009 06:46 PM
how to while in a ftp bash script dezeque Programming 3 06-12-2004 04:13 PM
BASH: FTP backup... elitecodex Programming 2 03-28-2004 11:30 AM
bash printf anyone? gumby Programming 4 05-13-2003 11:51 AM


All times are GMT -5. The time now is 06:39 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration