Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 05-26-2009, 04:43 AM   #1
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 707

Rep: Reputation: 55
ftp commands in shell script

hi all........

ftp localhost

i am trying to run above script ...

when i try to run it will ask for passwd and it will login correctly...

but in ftp> prompt ls and quit is not executing ...can anyone help me please....

Thanks in advance
Old 05-26-2009, 04:51 AM   #2
LQ Guru
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
You have to pass ftp commands as standard input to the ftp statement. Use a "here document" like in the following example:
ftp -ni host << EOF > /dev/null
user username password
Note that the closing EOF must be at the beginning of the line (no leading spaces or tabs) otherwise it is not interpreted from the shell and the standard input is not terminated. Also the user command let you avoid to interactively type username and password. A downside is that you have to write the password in clear text in a script and other people may read (and use) it.

Last edited by colucix; 05-26-2009 at 04:52 AM.
Old 05-26-2009, 08:32 AM   #3
LQ Guru
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
may i suggest scp
Old 05-26-2009, 10:59 AM   #4
Senior Member
Registered: Jun 2003
Location: California
Distribution: Slackware
Posts: 1,181

Rep: Reputation: 49
Originally Posted by schneidz View Post
may i suggest scp
For doing a simple `ls`, I think `ssh` may be more useful, but that's just my $0.02 -- there are many ways to arrive at the same goal!


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
shell script commands kushkothari Programming 3 10-20-2008 01:47 PM
commands in shell script ? wolfindark Linux - Newbie 5 07-07-2008 04:29 AM
help with shell script commands Andrew0 Linux - Newbie 1 04-15-2006 12:55 PM
Alias or shell script to confirm 'exit' commands from a shell rose_bud4201 Programming 2 03-08-2006 02:34 PM
Commands/Shell script ?? paraiso Linux - Newbie 11 04-21-2005 10:58 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:55 AM.

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