On Mon, Jan 03, 2000 at 09:23:54AM -0500, Michael J. McGillick wrote:
> Morning Everyone:

> I'm stuck on a small problem.  I'm trying to parse out the IP address of
> my DHCP server for a variable in a script.  From the command line, I've
> gotten this far:

>    pump -s | grep "Boot" | cut -f 2

> This yields:

>    Boot server 24.128.1.34

> Of course, when I looked at the output of the pump -s command, the only
> field I needed the IP address from was this, and, of course, there is no
> ":" to mark as a delimiter.  Notice all of the other fields have it.  My
> question is, how do I grab the IP address and not the other information?

> I'm going to eventually need to assign this to a variable in my ipchains
> firewall script, so I'm thinking the correct syntax will be:

>    variable_name = `pump -s | grep "Boot" | cut -f 2 ...`

> Any ideas?

        IPADDRESS=`expr $variable_name : '\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\)'

        This will find the first "doted quad" in the $variable_name string,
extract it, and set $IPADDRESS to it.

        man expr

> - Mike

        Mike
-- 
 Michael H. Warfield    |  (770) 985-6132   |  [EMAIL PROTECTED]
  (The Mad Wizard)      |  (770) 331-2437   |  http://www.wittsend.com/mhw/
  NIC whois:  MHW9      |  An optimist believes we live in the best of all
 PGP Key: 0xDF1DD471    |  possible worlds.  A pessimist is sure of it!


-- 
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.

Reply via email to