• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 212
  • Last Modified:

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
0
TheMaximumWeasel
Asked:
TheMaximumWeasel
1 Solution
 
TheMaximumWeaselAuthor Commented:
I can't use DynDNS this is mainly for when I go on vacation so I can tell when it changes.

Max
0
 
ravenplCommented:
MYIP=$( wget -q -O - http://whatismyip.org/ )
0
Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 
ravenplCommented:
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
0
 
probineCommented:
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
0
 
ravenplCommented:
> 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
0
 
probineCommented:
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.
0
 
ahoffmannCommented:
wget -q -O - http://whatsmyip.org/ | grep -i '<title>'| mail -s "IP" you@address.tld
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now