LinuxQuestions.org
Visit the LQ Articles and Editorials section
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 07-10-2005, 06:41 PM   #1
timgiffney
LQ Newbie
 
Registered: Oct 2004
Location: Auckland, New Zealand
Posts: 5

Rep: Reputation: 0
Shell Scripting - use the output of a command as an argument for another


I'm trying to set up a program to read my dynamic and natted ip address on my pda, then use ez-ipupdate to update the ip of my web page.

I figured out this command to get my external ip through the nat:

html2text (url of the check site) | cut -c21-35 | grep 2

This outputs my ip to the shell.
I then thought i'd do

html2text (url of the check site) | cut -c21-35 | grep 2 > ipaddress

Now I want to run

ez-ipupdate -a (the contents of the file ipaddress)

I can't run a better updater client as i'm fitting the entire distro into 16MB, and I have to put my page on that too.

How can I do this?

Thanks,
Tim
 
Old 07-10-2005, 06:47 PM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 368Reputation: 368Reputation: 368Reputation: 368
Code:
ez-ipupdate -a $( cat ipaddress )
Or you can do the whole smash in one command:
Code:
ez-ipupdate -a $( html2text <url of the check site> | cut -c21-35 | grep 2 )
 
Old 07-10-2005, 07:01 PM   #3
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,990

Rep: Reputation: 66
Or you might prefer:
Code:
ez-ipupdate -a `html2text <url of the check site> | cut -c21-35 | grep 2`
Note that ` is a back-tick, no an apostrophy (')
 
Old 07-10-2005, 07:41 PM   #4
timgiffney
LQ Newbie
 
Registered: Oct 2004
Location: Auckland, New Zealand
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks very much for your help - it works fine.

I actually tried rjlee's idea earlier, but it was the back tick that got me - i tried an apostrophe.

Thanks,
TIm
 
Old 07-10-2005, 08:23 PM   #5
ahh
Member
 
Registered: May 2004
Location: UK
Distribution: Gentoo
Posts: 293

Rep: Reputation: 31
Quote:
Originally posted by rjlee
Or you might prefer:
Code:
ez-ipupdate -a `html2text <url of the check site> | cut -c21-35 | grep 2`
Note that ` is a back-tick, no an apostrophy (')
Quote:
From the Advanced Bash Scripting Guide (http://advbash.activeventure.net/commandsub.html)

The $(COMMAND) form has superseded backticks for command substitution.
Just in case your interested...
 
Old 04-17-2006, 02:11 AM   #6
xode
Member
 
Registered: Aug 2003
Distribution: Mandrake 9.0; FC4; FC8; SUSE 10.3
Posts: 503

Rep: Reputation: 37
Quote:
From Dark_Helmet

ez-ipupdate -a $( cat ipaddress )
Your response here also answered my question, namely how to copy from
a terminal console to a file, as in:

cp $( tty ) file-to-be-copied-to
 
Old 04-17-2006, 11:13 AM   #7
dive
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,199

Rep: Reputation: 290Reputation: 290Reputation: 290
Also, instead of getting ip from website you could grab it straight from ifconfig with:

/sbin/ifconfig eth0 | grep "inet addr:" | awk -F: {'print $2'} | cut -d\ -f 1

Last edited by dive; 04-17-2006 at 11:14 AM.
 
  


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
goto/label command for scripting in bash shell terry.trent Linux - Software 3 07-09-2010 10:15 AM
Shell scripting: Print output to logfile, error to logfile & screen stefanlasiewski Programming 18 05-22-2008 12:47 PM
command line options for firefox for shell scripting. dr_zayus69 Programming 1 05-25-2005 11:36 AM
Redirecting output to a command-line argument of another command madiyaan Linux - Newbie 1 02-19-2005 04:35 PM
Assigning the output of one command to a variable (shell) guru_stew Programming 5 08-03-2003 06:12 PM


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

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