LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Shell Scripting - use the output of a command as an argument for another (https://www.linuxquestions.org/questions/programming-9/shell-scripting-use-the-output-of-a-command-as-an-argument-for-another-341980/)

timgiffney 07-10-2005 06:41 PM

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

Dark_Helmet 07-10-2005 06:47 PM

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 )

rjlee 07-10-2005 07:01 PM

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 (')

timgiffney 07-10-2005 07:41 PM

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

ahh 07-10-2005 08:23 PM

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...

xode 04-17-2006 02:11 AM

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

dive 04-17-2006 11:13 AM

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


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