Jump to content
xisto Community
Sign in to follow this  
m3th1405241494

Bash Script To Display Your Ip Script to display your ip

Recommended Posts

If your behind a router , and like me too lazy to open a browser and find a site that displays your ip , heres a simple Bash script (Bash is a shell in linux, main shell in Slackware Linux)

Open a text editor , copy and paste the following:

#! /bin/bashexip=`lynx -dump https://www.whatismyip.com/ | head -n 2`echo "$exip"

Save the txt ( for the sake of agrument we will refer the file as ip.sh)
From console type:
chmod a+x ip.sh
Now run the script like so:
./ip.sh (which will display something like the following)
Your IP Is XX.XXX.XXX.XX
Done!

I will explain what we just did in the script.

!# /bin/bash <- Tells what shell we using, this line is always here but /bin/bash may be changed, depending on your system

exip=`lynx -dump https://www.whatismyip.com/ | head -n 2` <- We setup a variable and run some console commands, lynx is a txt mode browser the we send it to head, which takes only the first to lines.

echo "$exip" <- We echo the content of exip variable to screen

chmoding to a+x just makes the file executable..

I know there a billion ways to do this, but it gets job done ...

Share this post


Link to post
Share on other sites

You could/should also include links instead of lynx. Usually links is installed, for lynx you have to select individual packages, which not everyone does. (I do but that's not the point :D)In any way, Links looks better than lynx. And the speed of both is the same :DIt's not a very long tutorial but it's nice.

Share this post


Link to post
Share on other sites

Nice tutorial.. Though my IP changes every once in a while and I've never had to know it for anything. But if we ever get stuck in linux and need to know .. :D

Share this post


Link to post
Share on other sites

You could/should also include links instead of lynx. Usually links is installed, for lynx you have to select individual packages, which not everyone does. (I do but that's not the point :rolleyes:)
In any way, Links looks better than lynx. And the speed of both is the same B)

It's not a very long tutorial but it's nice.


Why lynx? wget is more common on unix based default installs these days than lynx or links or elinks (or any other text browser for that matter).

Share this post


Link to post
Share on other sites

Null password at Freewebs

Bash Script To Display Your Ip

 

I accidentally pressed Enter key without assigning a new password in my freewebs.Com site. Now they say my password is "null".

 

Any help available to recover my site?

 

-reply by Cherian

Share this post


Link to post
Share on other sites
re: darkkenBash Script To Display Your Ip

darkken: ifconfig gives you your internal IP (ie. The one your router gave you). If you want your network's external IP (ie. The one the internet sees), then the only real way is with external websites.

Share this post


Link to post
Share on other sites

! /bin/bash

exip=`lynx -dump https://www.whatismyip.com/ | head -and 11`
#Echo "$exip"
curl -o /dev/null -s -u twittername:twitpasswd -d status="$exip" http://forums.xisto.com/no_longer_exists/




Now if you setup a misc twitter account you can send this information to you if you happen to be on the road and need to know the ip to get in.

just insert your new twittername and paswd here and be sure to make those tweets private and then follow with your primary twitter account.


I use this from everything to knowing if root logs in to server powerdown and reboots.......

Very handy.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.