Skip to content

Instantly share code, notes, and snippets.

@zpeters zpeters/whereami.tcl

Created Feb 27, 2017
What would you like to do?
#!/usr/bin/env tclsh
package require http
## Settings
set homeGateways {}
### Procs
proc whereAmI {} {
global homeGateways
set tok [::http::geturl ""]
set body [::http:::data $tok]
set ip [string trim [string map {"\"" ""} [lindex [split [lindex [split $body "\n"] 1] ":"] 1]]]
if {[lsearch $homeGateways $ip] >= 0} {
return "Home"
} else {
return "Remote"
### Main
puts [whereAmI]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.