This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

How to get the IP of my bot?

Old posts that have not been replied to for several years.
Locked
d
doggo18

Post by doggo18 »

I need to grab the IP of my bot in TCL so it can refer you to the stats pages its generating... how?

thanks!
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

in the script that dsplays the IP. Make sure the "my-ip" variable is global, and use it's value to refeer users.
d
doggo18

Post by doggo18 »

yes but the problem is the -...
if i do $[my-ip] it says no such command "my-ip"

without [] its nu such variable: $my

plz help :smile:
P
Petersen
Owner
Posts: 685
Joined: Thu Sep 27, 2001 8:00 pm
Location: Blackpool, UK

Post by Petersen »

${my-ip}
d
doggo18

Post by doggo18 »

tried that... result was empty... :/
d
doggo18

Post by doggo18 »

is there another variable what holds the IP perhaps?
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

No, this is the only variable that hold the IP - if this is empty, then you have not setup your bot correctly in the first place.

Read over your config file.
d
doggo18

Post by doggo18 »

ive set it up correctly for as far i can tell... It does connect to the network, accepts DCCs, all commands work fine...
And it doesnt say anywhere i have to set it myself...

Sorry admin for the new topic :smile:
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Without "my-ip" being set in the config file, there are no simple ways to detect the IP of the machine.
d
doggo18

Post by doggo18 »

but how in earth am i gonna find out my IP with a dynamic IP then thru my bot??

Else, give me the hardway... Like a way that extracts the IP from eth0 on connect... :smile:
R
RedAlert
Voice
Posts: 17
Joined: Mon Nov 19, 2001 8:00 pm

Post by RedAlert »

This would be *extremely* ugly but if you're running Linux and you KNOW you are gonna use the IP from eth0, you could do something like

Code: Select all

set my-ip [exec /sbin/ifconfig eth0 | grep inet | head -1 | cut -d: -f2 | cut -d  -f1]
which would set the IP using ifconfig (note that you could also do the manipulation of the output using TCL). Typically the if-everything-else-fails kind of solution...
G
Guest

Post by Guest »

The command myip will return your ip.
example: putlog [myip]
W
Wcc
Master
Posts: 278
Joined: Sun Oct 28, 2001 8:00 pm
Location: USA
Contact:

Post by Wcc »

You can get the IP of your bot with the following code:

Code: Select all

proc getrealip {} {
  binary scan [binary format I [myip]] cccc a b c d
  return [format %d.%d.%d.%d [expr $a&255] [expr $b&255] [expr $c&255] [expr $d&255]]
}
Locked