Get you ip address like whatismyip.com

For last couple of days, I was thinking of putting this. I was thinking of some way to get the IP address of the client directly rather than going through some site or parsing the content. So here it is.

Now the trick here is simple. There are two ways to get the IP address of the client in the php script and thus a simple script like the below would capture both of them.

<?php

[email protected]$REMOTE_ADDR;
echo \”<html><body><font size=\’3\’><b>IP Address= $ip</b><br>\”;
$ip1=$_SERVER[\’REMOTE_ADDR\’];
echo \”<font size=\’3\’><b>IP Address= $ip1</b>\”;
?>
</body></html>

Now this can be used in scripts to get you IP address very quickly if only there were no html tags and no junk and only the IP address. So here is a direct link to your IP alone.

This is a php which does not create any text and thus you can get the IP adress directly without parsing too. There are two lines in the file and both contain the IP address 🙂

Here is an example to use in bash scripts:

wget http://amit-agarwal.co.in/mystuff/getip_txt.php -O ak 2>/dev/null && ip=`tail -1 ak`

After you have executed the above the IP address used by your client is put in the variable ip. You can check this with http://whatismyip.com for this first time to verify it is working fine. So enjoy scripting.

Personal Page and space.

Now that my other url is working, I can afford to share some space. If you want to try something on web programming or something else, mail me and I will personally try to see if I can arrange to make some permission chages for you. I am not launching anything for a free service, but for my readers, this is exclusive offer. I will try to arrange something.

My HomeGrown Free web address with unlimited space for no charge.

I have a broadband connection and have been trying to do this for a while. I wanted to setup a URL that could link to my system at my home at \”no extra cost\”. To start with this is for fun and finally for profit. As you know, buying a space on the web now a days is costly and I believe saving money is earning money and thus did the setup so that I have a URL that can go directly to my system behind the ADSL router.

Check this out:
amit.themafia.info

This is link for phpMan on my system so might not be available at all times, but will try to keep it up and running all the time. I have fixed most of the issues with my system wrt hardware and have been running it for 4 days without re-start before trying this. So do comment if you like it. Will soon write on how I did this.