Where is this computer in the world?
- Posted by ChrisB (moderator) Nov 25, 2012
- 1235 views
Here's a very quick snippet to find out where this particular computer is in the internet world (linux only)
include std/io.e include std/filesys.e sequence ifile, thiscomp = {}, extaddr = {} system("/sbin/ifconfig > if.txt", 0) ifile = read_lines("if.txt") for i = 1 to length(ifile) do if match("inet addr:", ifile[i]) > 0 then thiscomp = "This computer " & ifile[i][match("inet addr:", ifile[i])..$] exit end if end for system("wget -q http://automation.whatismyip.com/n09230945.asp", 0) extaddr = read_lines("n09230945.asp") extaddr = "External ip = " & extaddr[1] puts(1, thiscomp & "\n") puts(1, extaddr & "\n") delete_file("wget.log") delete_file("n09230945.asp") delete_file("if.txt")