I hope you know about the possibility to find out your IP Address by using visiting the site http://www.whatismyip.com . I needed a way to check this from the command line and this is what I came up with:
For this, you need the packages wget, grep and sed so make sure you have them by checking for them in Synaptic or running the following in a terminal:
Then, as long as whatismyip.com prints out the IP-Address in the HTML page title, you can use this:
sudo apt-get install wget grep sed
Create shell script:
Insert this into nano (Copy, then paste into nano by pressing Ctrl + Shift + V):
(You can also use gedit instead of nano, but I chose to use nano above in case this is done through a remote text-based connection)
echo Your external IP Address is:
wget http://Www.whatismyip.com -O - -o /dev/null | grep '<TITLE>' | sed -r 's/<TITLE>WhatIsMyIP\.com \- //g' | sed -r 's/<\/TITLE>//g'
Press Ctrl + O, Enter, Ctrl + X, then run:
Now you can check your external IP Address by running:
chmod u+x bin/whatismyip.sh
...in a terminal.