Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Sending my IP address via email with sendmail?

2 views
Skip to first unread message

Jourdain Casale

unread,
Aug 28, 2000, 3:00:00 AM8/28/00
to
Hello, I need a bit of help.

I'm trying to send my current ip address to myself once a day through
sendmail by using a cron job that would sendmail to my address and grep
ifconfig. i'm using dchp. does anybody have any ideas???

THANKS!

john

unread,
Aug 28, 2000, 3:00:00 AM8/28/00
to
Jourdain Casale wrote:

Well, here's bit's and pieces from a perl script I used to use when all I
had was a dialup. There was a ton more to it, but I copied the relevant
material. You can expand as you wish, but it should get the job done. If
it looks clumsy it's because I wrote it when I was trying to get
reacquainted with perl. <G> Now, I'd just convert it to a bash script.
Make sure your perl at least has a link in /usr/local/bin to perl's correct
location, or change the shebang line to where it lives <G>

#!/usr/local/bin/perl

# Set up variables

$mailprog = '/usr/lib/sendmail';
$ipfile='/var/tmp/ipaddress';

system ("/sbin/ifconfig ppp0 > $ipfile"); # Create ppp info to message
file

open (IPAD, "$ipfile") || die "Can't open IP Address File!\n"; # Open
message file

while (<IPAD>) { # Read message file and store
info
$message .= $_;
}

close(IPAD); # Close message file

mailsub();

unlink ("$ipfile");

exit;

sub mailsub
{
open (MAIL, "|$mailprog -t") || die "Can't open $mailprog!\n";
print MAIL "To: You <you\@whateveraddress.com>\n";
print MAIL "From: You <you\@whateveraddress.com>\n";
print MAIL "Subject: IP Address\n";
print MAIL "\n\n This is the current IP info....\n\n";
print MAIL $message;
close MAIL;
}

--
Please remove '-the-hobit' for Email reply...

David ..

unread,
Aug 28, 2000, 3:00:00 AM8/28/00
to
Jourdain Casale wrote:
>
> Hello, I need a bit of help.
>
> I'm trying to send my current ip address to myself once a day through
> sendmail by using a cron job that would sendmail to my address and grep
> ifconfig. i'm using dchp. does anybody have any ideas???


This script isn't anything fancy but does what you want.

-----------------------------------------------------
#!/bin/sh
#
# This script will get the IP address of a dial-up connection,
# and mail it to root or "us...@address.com".
#
# Edit the "us...@address.com" to point to user you want mail
# to be delivered to.
#
# Then: chown 0.0 this script
# chmod 755 this script
# Then place a line in /etc/ppp/ip-up.local to point to the
# /path/to/script
# or it can be set to run as a cron job.
#

/sbin/ifconfig | /bin/grep P-t-P | /usr/bin/cut -c 21-35 | mail
us...@address.com

----------------------------------------------------------

Hope it helps
--
Confucius say: He who play in root, eventually kill tree.
Registered with the Linux Counter. http://counter.li.org
ID # 123538

0 new messages