in reply to localhost IP in a dollar sign

Lots of people are behind (NAT) routers these days. If you're behind such a device and you want to see your external IP address (not the 192.168.... one), then feel free to use LWP or whatnot to fetch this url and parse the simple document it returns. (But please don't use this in code that's distributed to more than a handlful of people. Put the attached code on your own server instead.)
---------- BEGIN /cgi-bin/ip_addr ---------- #!/bin/sh cat << __EOI__ Content-Type: text/html <html> <head> <title>ip address</title> </head> <body> <p>Your ip address is $REMOTE_ADDR.</p> </body> </html> __EOI__ ----------- END /cgi-bin/ip_addr -----------

Update: Come to think of it, my script was meant for human eyes. If you wanted something for a script to read, it would be rewritten as:

---------- BEGIN /cgi-bin/ip_addr_as_text ---------- #!/bin/sh cat << __EOI__ Content-Type: text/plain $REMOTE_ADDR __EOI__ ----------- END /cgi-bin/ip_addr_as_text ----------- ---------- BEGIN client code ---------- use LWP::Simple (); $content = LWP::Simple::get("http://bla/cgi-bin/ip_addr_as_text"); die(...) unless (LWP::Simple::is_success()); chomp($content); ----------- END client code -----------

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.