wm title . {Force renew ip} wm iconname . {Force renew ip} wm geometry . 225x65+500+100 # # Author : DFL # Version : 1.2 # Date : May 2010 2008 # Licence : Creative Commons BY-SA # Description # uses ipconfig to query the ip address and force the renewal of a dhcp address, # Version Comment: # The proc renew IP needs to be improved. # shall I bind it to the wifi port # it should report the connection name, and check that there # is only one active # Prerequisites # This program requires the Boomy Icons to be copied to # the TCL images folder. # This is not part of the package, it needs to be copied here image create photo infopic -file [file join $tk_library images app24.gif] # This is for windows XP/vista, we only run the external program once to get the IP facts set confreply [exec ipconfig] # Two lines for clarity, first extract the IPv4 line, set interestingstring [ lrange $confreply [ lsearch $confreply "IPv4" ] [ expr [ lsearch $confreply "IPv4" ] + 20 ]] # then extract the IP address itself set daddress [ lrange $interestingstring [ expr [ lsearch $interestingstring ":" ] + 1 ] [ expr [ lsearch $interestingstring ":" ] + 1 ] ] frame .top frame .bottom label .top.icon -image infopic frame .top.f -width 50 label .top.f.mess1 -text " private tcp/ip no : " label .top.f.mess2 -text $daddress pack .top.f.mess1 .top.f.mess2 -side left -fill x pack .top.icon .top.f -side left button .bottom.discover -text " Query " -command "getPrivateIP" button .bottom.renew -text " Renew " -command "renewIP" button .bottom.dismiss -text " Done " -command "exit" pack .bottom.discover .bottom.renew .bottom.dismiss -side left -padx 4 -pady 2 pack .top .bottom proc getPrivateIP {} { set ipconfigtext [exec ipconfig ] set interestingstring \ [ lrange $ipconfigtext \ [ lsearch $ipconfigtext "IPv4" ] \ [ expr [ lsearch $ipconfigtext "IPv4" ] + 20 ]] set iaddress \ [ lrange $interestingstring \ [ expr [ lsearch $interestingstring ":" ] + 1 ] \ [ expr [ lsearch $interestingstring ":" ] + 1 ] ] destroy .top.f.mess2 label .top.f.mess2 -text $iaddress pack .top.f.mess1 .top.f.mess2 -side left -fill x } proc renewIP {} { exec ipconfig /renew # there are almost certainly better ways of indicating that a renewal has taken # place but this is where I am leaving it getPrivateIP } proc exit {} { destroy . }