Morgan Wajda-Levie on Sat, 18 Sep 1999 23:47:16 -0400 (EDT)


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [Plug] Bash script


On Sat, Sep 18, 1999 at 10:37:34PM -0400, George McNeal wrote:
> I want to write a script that parses the local eth0 IP address out of
> /sbin/ifconfig and assigns the value to a variable (loceth0) and later
> use $loceth0 as a value.  The following executed on a command line gives
> the correct IP.:
> 
> /sbin/ifconfig | grep -A 4 eth0 | awk ' /inet/ { print $2 } ' | sed -e
> s/addr://
> 
> However, if I write
> 
> loceth0='/sbin/ifconfig | grep -A 4 eth0 | awk ' /inet/ { print $2 } '
> sed -e s/addr:// '
> 
> I get errors.  I am using the Bash shell.  What is the correct syntact
> or is there another route?

You may want to try enclosing the command in reverse quotes "`".
I don't actually know a whole lot about shell scripting, but that's
what you do in perl.

-- 
Morgan Wajda-Levie
http://www.worldaxes.com/wajdalev
PGP fingerprint:
A353 C750 660E D8B6 5616  F4D8 7771 DD21 7BF6 221C
http://www.worldaxes.com/wajdalev/public.asc for PGP key
encrypted mail preferred

Attachment: pgpszPVs5dyHC.pgp
Description: PGP signature