Jump to content



Welcome to AstaHost - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!

Toggle shoutbox Shoutbox Open the Shoutbox in a popup

@  agyat : (24 May 2013 - 05:15 PM) O Dear, Where Are You? Without Your Words This Sb Is ..
@  agyat : (23 May 2013 - 01:23 AM) Wow! Mr. Sb Back Home.
@  OpaQue : (23 May 2013 - 12:44 AM) Ting
@  OpaQue : (24 April 2013 - 02:44 PM) I guess, Time to run Mycent script.
@  OpaQue : (24 April 2013 - 02:43 PM) wow.. not much spam. except habatt posting lot of links.. :P
@  yordan : (23 April 2013 - 01:04 PM) You're welcome, agyat. Nice to have been helpful. Second lesson: try full words, "you" instead of "EW".
@  agyat : (23 April 2013 - 05:03 AM) @YORDAN: tHANK EW FOR YOUR FIRST LESSON.   :D
@  yordan : (22 April 2013 - 09:43 PM) @agyat : "why don't you help me", or "please help me", or "please teach us"
@  yordan : (22 April 2013 - 09:42 PM) welcome back, velma
@  velma : (22 April 2013 - 07:51 AM) **yawns** Good to be back, wonder what is going on here :)
@  agyat : (22 April 2013 - 03:50 AM) Oh! so, why don't help me learn english..
@  yordan : (21 April 2013 - 08:38 PM) The goal mentioned by shiu : "learning english, learning computer"
@  agyat : (21 April 2013 - 06:31 PM) WHAT GOAL?
@  yordan : (20 April 2013 - 10:39 AM) yes, that's our goal. simultaneouly learning English and teaching/learning computer using.
@  shiyu : (20 April 2013 - 07:30 AM) learning english,learning computer
@  yordan : (19 April 2013 - 01:11 PM) Oh, I see, it's just a trick in order to force people looking at your texte. Somehow smart, maybe.
@  agyat : (19 April 2013 - 02:54 AM) And of course I know it is not SEO friendly.
@  agyat : (19 April 2013 - 02:52 AM) There may be two possible answers for that ....


1) Shout was posted using mobile keypad.

2) To force people read content carefully and/or with more concentration.
@  agyat : (19 April 2013 - 02:49 AM) There may be two possible answers for that ....
@  yordan : (18 April 2013 - 09:35 PM) however, why this mixing of capital letters in the middle of your text?

Photo
- - - - -

Bash Script To Display Your Ip


12 replies to this topic

#1 m3th

m3th

    Newbie [ Level 1 ]

  • Members
  • 1 posts

Posted 16 May 2005 - 10:28 PM

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/bash

exip=`lynx -dump http://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 http://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 ...

#2 moonwitch

moonwitch

    Demonic Enforcer

  • [HOSTED]
  • 598 posts
  • Gender:Female
  • Location:Belgium
  • Interests:I used to have too many to list here, now I can honestly say one of my interests is finding those annoying spammers on the forums and hunting them down. Ok, I also enjoy skinning IPB and just general webdesign. You may seduce me with some XUL or XML as well :)

Posted 27 May 2005 - 08:17 AM

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 :D

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

#3 jet

jet

    Advanced Member

  • Members
  • 140 posts
  • Location:Australia
  • Interests:Roleplaying, art, music, web design

Posted 27 May 2005 - 08:39 AM

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

#4 OldSkuBoi

OldSkuBoi

    Newbie [ Level 2 ]

  • Members
  • 27 posts

Posted 27 May 2005 - 08:14 PM

lol nice tuturial. I would use it but, my ip stays the same. Been the same ip for like over 1 year. Maybe i should reset my ip.

#5 saneax

saneax

    Member [ Level 2 ]

  • Members
  • 72 posts

Posted 02 September 2005 - 06:42 AM

nice script..I find it usefull.. good work!

#6 SiriusRo

SiriusRo

    Newbie [ Level 2 ]

  • Members
  • 14 posts

Posted 11 December 2007 - 04:35 AM

Does this display my ip address or the person who is looking at the script's ip address, or does it show everyone my ip address

#7 toby

toby

    Super Member

  • Members
  • 611 posts

Posted 11 December 2007 - 01:18 PM

Bash is non-windows Command Prompt.

Nice idea, I'm surprised it works.

#8 ethergeek

ethergeek

    Premium Member

  • [HOSTED]
  • 393 posts
  • Gender:Male
  • Location:Tucson, AZ

Posted 11 December 2007 - 05:13 PM

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).

#9 Guest_FeedBacker_*

Guest_FeedBacker_*
  • Guests

Posted 21 April 2008 - 02:10 PM

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

#10 darkken

darkken

    Newbie [ Level 2 ]

  • [HOSTED]
  • 26 posts

Posted 24 July 2008 - 10:11 AM

Why can't you use ifconfig built-in to display the ip address. Simple and works great.

#11 Guest_(G)silv3r_*

Guest_(G)silv3r_*
  • Guests

Posted 08 December 2008 - 09:08 PM

renew script bashBash Script To Display Your Ip

! /bin/bashexip=`lynx -dump http://www.Whatismyip.Com | head -and 11`Echo "$exip"

-reply by silv3r

#12 Guest_(G)_*

Guest_(G)_*
  • Guests

Posted 08 May 2009 - 02:12 AM

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.



#13 dmnhunter

dmnhunter

    Newbie [ Level 1 ]

  • Members
  • 1 posts

Posted 29 August 2009 - 12:16 AM

! /bin/bash

exip=`lynx -dump http://www.Whatismyip.Com | head -and 11`
#Echo "$exip"
curl -o /dev/null -s -u twittername:twitpasswd -d status="$exip" http://twitter.com/statuses/update.xml




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.



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users