On Fri, 12 Nov 1999,  Tim Howell wrote:
> Hi,
> 
> Just wondering if anyone more familiar with shell programming than I had
> any ideas how to write a script that would take a client's IP address (as
> assigned by a DHCP server) and email to a user?  I have recently
> configured my system as a DHCP client, and would like such a script, to
> avoid having to log on to my firewall machine and run ifconfig.  Any
> ideas?

I think you can write this yourself.  If you look at the
output of the command  /sbin/ifconfig
you will see that the IP address is there.

All you need now is for it to be emailed.

Here is a CRUDE way to do this. 

1. Redirect the output of the command to a file.
2. Email the file.

1. 
/sbin/ifconfig > /home/rfg/myip.address

2. 
cat /home/rfg/myip.address | mail -s IPAddress [EMAIL PROTECTED]

YOu can combine the above two statements into a script
file.  How you "trigger" the thing is up to you.  I
am going to make a suggestion.

If the connection is as a result of a dialup connection,
the you can include the script in the dialup startup,
but give it enough time to make a connection and negotiate
an IP address.  The command "sleep 60" will do that.  Just
add the three lines; ie, sleep60, then #1 then #2 to the
end of your ppp startup script.  

You can add more, like to use the directive "cut" to
parse your text file prior to emailing it, etc.  But I
think the above will get you started.

If you are on an ethernet, I am not sure what would trigger
it, but you could look at the dhcp command and see what
calls it, then append it.  If dhcp is a binary file, you
can write a wrapper script.

dhcp binary renamed to dhcp.bin

write a script called dhcp and put it in the same directory
as dhcp.  

The script has the following sequence
dhcp.binary
sleep statement
line 1
line 2

That ought to get you started in becoming a script writer.
It is crude, but its a start.

-- 
Ramon Gandia ============= Sysadmin ============== Nook Net
http://www.nook.net                            [EMAIL PROTECTED]
285 West First Avenue                     tel. 907-443-7575
P.O. Box 970                              fax. 907-443-2487
Nome, Alaska 99762-0970 ==== Alaska Toll Free. 888-443-7525

Reply via email to