On Mon, 21 Sep 1998, Omar El-Domeiri wrote:

> And the script could run ifconfig eth0 for exapmle
> with a grep for the IP address
> then run mail to send it .

  Two simple ways to do this, depending if you have sed or not.

ifconfig eth0 | grep "inet addr:" | cut -f 2 -d : | cut -f 1 -d " "

ifconfig eth0 | grep "inet addr" | cut -c 21-35 | sed "/ /s///g"

or even in perl

#!/usr/bin/perl
$ip = `ifconfig eth0`;
$ip =~ m/inet addr:(\d+\.\d+\.\d+\.\d+)/;
$ip = $1;

   Of course these depend on your ifconfig spitting out the same output as
mine did.  netstat -rn or something could have been used too actually,
probably easier too.
netstat -rn | grep eth0 | cut -f 1 -d " "
shoud work.

   Adam

        __/\__.             [-Temperance-]                 .__)\__
   !    \ oO /           . :[Adam Rogoyski]: .              \ oO /    !
   .    /_\/_\         .  :[ [EMAIL PROTECTED] ]:  .           /_\/_\    . 
      .   \/   :[http://ccwf.cc.utexas.edu/~apoc/programs]:   \/   .

---------------------------------------------------------------------------
Send administrative requests to [EMAIL PROTECTED]

Reply via email to