LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-05-2006, 09:53 AM   #1
bokini
LQ Newbie
 
Registered: Oct 2003
Posts: 9

Rep: Reputation: 0
grab FTP output in bash script


script:

#!/bin/sh
HOST='80.172.10.255'
USER='ahahahah'
PASSWD='eheheheh'
ftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
put file <--------- i want to grab the command result into a bash variable to hadle it #here
quit
END_SCRIPT

#here

exit 0
 
Old 01-05-2006, 10:52 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

This 'solution' will grab all the output the ftp session creates, not only the line specified (put file). So this could not be what you are looking for.......

Code:
#!/bin/sh
HOST='80.172.10.255'
USER='ahahahah'
PASSWD='eheheheh'

OUT="$(ftp -n $HOST 2>&1 <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
put file
quit
END_SCRIPT
)"

echo "Output is: $OUT"

exit 0
Hope this helps.
 
Old 02-03-2006, 02:11 PM   #3
WilliamsJD
LQ Newbie
 
Registered: Nov 2003
Distribution: Fedora Core 4
Posts: 11

Rep: Reputation: 0
You may want to look at using lftp instead... it has a simpler syntax for scripting FTP sessions than the standard ftp client and will produce a lot less output (more relevant output).

output=$(lftp -c "put file" -u$USER,$PASSWD)

WilliamsJD
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script to output only differences in two files czarherr Programming 4 11-08-2004 06:25 PM
bash:output file names from shell script to vi sickboy Linux - Newbie 6 10-14-2004 03:40 AM
bash-script: output text between two ocurrences of a specific string isl01jbe Programming 1 06-17-2004 02:36 PM
grab - Simply a useless bash script to take a screen shot; Required command: import micxz Programming 2 10-08-2003 07:59 PM
Bash script: add all numbers from command output wi-Z-art Programming 2 08-06-2003 09:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:21 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration