Tag: wget

Display your current external IP address with WGET

To know your ip address , you can use the command ifconfig
You will know the ip address for each of your network interfaces.

But if you are not directly connected to the internet and use a Gateway that’s nating the internet traffic for you , ifconfig is not going to be helpful to know the ip that connect you to the internet.

with this command the current external ip address associated with you default gateway will display

wget -qO - ident.me

bash : Put the source of a webpage in a variable

When you do some bash scripting , this is often useful to get data from  webserver because they are a very simple way to exchange data from computer from computer.
to put the data that’s available on a webserver into a $var you just have to use the command :

 var=$(wget -qO- http://server.com/file.htm)

this will fetch the data from http://server.com/file.htm in a non verbose way and put it in variable named var .

you can now do whatever you want with that $var , like greping it for example.