TheMaximumWeasel
asked on
Get Server IP address?? 500 POINTS!!!!
I need a shell script or something that can find my external ipaddress then email it to me through postfix/sendmail/qmail.
Max
Max
http://www.tek-tips.com/viewthread.cfm?qid=1202304&page=2
ASKER
I can't use DynDNS this is mainly for when I go on vacation so I can tell when it changes.
Max
Max
MYIP=$( wget -q -O - http://whatismyip.org/ )
Oh, and the second part with email
MYIP=$( wget -q -O - http://whatismyip.org/ )
DATE=$( date )
cat << EOF | mail -s "My current IP = $MYIP" you@address.tld
Hi,
my name is bla bla
current date: $DATE
current ip: $MYIP
EOF
MYIP=$( wget -q -O - http://whatismyip.org/ )
DATE=$( date )
cat << EOF | mail -s "My current IP = $MYIP" you@address.tld
Hi,
my name is bla bla
current date: $DATE
current ip: $MYIP
EOF
By letting an external program to tell you the IP of your computer you are taking the risk that it won't be correct. This situation will occur if you are behind some type of firewall. The external program or web page will tell you the IP of your Network's firewall and not the one you have in your computer.
If I were you I will do the following:
Grand permision to a user in your computer (your self) to access the "ifconfig" command. Usually "ifconfig" is only accessed by root, so "root" could also sent tou the email, though I will advice you to access it as a regular user.
Once the access is granted, then you can run the "ifconfig" and save it in a file. Something like: "ifconfig > ip.txt"
Finally you could sent the email: mail -s "My Server's IP info" yourname@yourhost.com < ip.txt
If I were you I will do the following:
Grand permision to a user in your computer (your self) to access the "ifconfig" command. Usually "ifconfig" is only accessed by root, so "root" could also sent tou the email, though I will advice you to access it as a regular user.
Once the access is granted, then you can run the "ifconfig" and save it in a file. Something like: "ifconfig > ip.txt"
Finally you could sent the email: mail -s "My Server's IP info" yourname@yourhost.com < ip.txt
> Grand permision to a user in your computer (your self) to access the "ifconfig" command
any use may addess this command
/sbin/ifconfig
/sbin/ip addr
any use may addess this command
/sbin/ifconfig
/sbin/ip addr
yes, any user may access that command, so I will advice you to create a group that will only contain your self as a user. So only the group (you) can access it.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.