Prev: Confounded by conditional expressions
Next: Can I test for the existence of a filetype when I don't know any filenames?
From: Kenny McCormack on 12 Jul 2010 17:40 In article <1381c81f-3c06-4161-a4da-7b487765c4bc(a)w37g2000prc.googlegroups.com>, laredotornado <laredotornado(a)zipmail.com> wrote: .... >Thanks for this excellent, concise solution. That was indeed the >simple answer I was looking for, - Dave But you do realize, as I alluded to in my post, that this isn't a 100% genuine, pure-blue-ribbon solution, since it depends on Chris (or whoever - not meaning to single Chris out here) maintaining his site. I.e., you have to rely on some external site to return you the info you need. I'm not saying this is a problem, but at some point in the distant future it can and will be. As someone else noted, it is also possible to scrape the info from your router, if you care to go that route. This method doesn't depend on any arbitrarily chosen external site. -- (This discussion group is about C, ...) Wrong. It is only OCCASIONALLY a discussion group about C; mostly, like most "discussion" groups, it is off-topic Rorsharch [sic] revelations of the childhood traumas of the participants...
From: Keith Keller on 12 Jul 2010 18:00 On 2010-07-12, Kenny McCormack <gazelle(a)shell.xmission.com> wrote: > > As someone else noted, it is also possible to scrape the info from your > router, if you care to go that route. This method doesn't depend on any > arbitrarily chosen external site. ....but does depend on the idiosyncracies of the individual router, many of which may not support unauthenticated HTTP requests to scrape the IP. (Yes, if it's basic HTTP auth, the auth information can be added to the wget, but it's just one more thing to remember.) --keith -- kkeller-usenet(a)wombat.san-francisco.ca.us (try just my userid to email me) AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt see X- headers for PGP signature information
From: Lao Ming on 12 Jul 2010 18:49
On Jul 12, 11:44 am, laredotornado <laredotorn...(a)zipmail.com> wrote: > Hi, > > I'm using Mac 10.6.3, bash shell. How can I get my IP address, as it > would appear in a web server log of a remote server (assuming no > proxies in between)? I would like to get this IP address and put it > in a file on my system. > > Thanks, for your help, - Dave Some web server logs use the DNS name and some use just the numeric IP address. Thus, you would have to know this in advance. If the local host is a DHCP client using a wired connection, you can use: ipconfig getifaddr en0 or for wireless and DHCP, use ipconfig getifaddr en1 That's ipconfig (not ifconfig) in the above case. Otherwise, for wired, use: ifconfig en0 |grep "inet " |awk '{print $2}' and wireless: ifconfig en1 |grep "inet " |awk '{print $2}' Once you have the IP address, you can get the DNS name with: ipaddr=$( ifconfig en0 |grep "inet " |awk '{print $2}' ) dnsname=$( dig -x "$ipaddr" +short ) echo ${dnsname%.*} # you have to remove the trailing dot |