Hi Tom,
I wrote a shell script for the same purpose. Here it is:
#!/bin/sh
NewIP="`/sbin/ifconfig ppp0 | grep 'inet addr' | awk '{print $2}' \
| sed -e 's/.*://'`"
if [ -e /home/rjonasz/ip.txt ]; then
OldIP=$(cat /home/rjonasz/ip.txt)
else
OldIP=""
fi
if [ "$OldIP" != "$NewIP" ]; then
echo $NewIP | mail -s "Foucault's IP Address has changed!" \
"[EMAIL PROTECTED]"
echo $NewIP > /home/rjonasz/ip.txt
fi
Hope this helps,
Randy
On Wed, 27 Feb 2002, Tom Badran wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> How can i use an if in a bash script so that it will only run commands if the
> specified file is empty?
>
> Basically, ive set up a cache system by which the output of ifconfig is
> stored in /var/cache/IP/1
>
> Then, every minute my script is run. It first puts the output of ifconfig in
> /var/cache/IP/2 and diff's it with 1 outputing that to a file 'diff'. I then
> want to run a series of commands if the file diff is not empty.
>
> What im trying to do is get an email sent to me every time the IP changes on
> a specific machine, so i always have a record of it for logging in via ssh.
> The specific connection is ppp0 which auto redials on disconnect. If there is
> an easier way of doing this please share with me.
>
> Thanks
>
> Tom
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.0.6 (GNU/Linux)
> Comment: For info see http://www.gnupg.org
>
> iD8DBQE8fWUSXCpWOla2mCcRAmyuAJ0dNeH725n8jc0UhaeIYgdxlerG3wCfQwtM
> mEDR987gtUilwovjGKbV3b8=
> =IODe
> -----END PGP SIGNATURE-----
>
>
--
Under any conditions, anywhere, whatever you are doing, there is some
ordinance under which you can be booked.
-- Robert D. Sprecht, Rand Corp.
Want to buy your Pack or Services from MandrakeSoft?
Go to http://www.mandrakestore.com