rdesktop and Tcl/tk

16 Jan 2009 . . Comments

#Linux #Windows #tcl #script #systems administration

This is something I did a few years ago and has been very useful. I'm a *nix admin that occasionally needs to log on to a Windows server. I used rdesktop for a long time to do this. I wanted, though, a nice GUI that would allow me to pick which server I wanted (and an excuse to play a bit with Tcl). This is the script I came up with to do just this:

#! /usr/bin/wish

wm title . "Remote Desktop Launcher"

frame .top -borderwidth 10
pack .top -side top -fill x

button .top.quit -text Quit -command exit
set but [button .top.run -text "Launch" -command Run]
pack .top.quit .top.run -side right

label .top.l -text Server: -padx 0
entry .top.cmd -width 20 -relief sunken -textvariable server
pack .top.l -side left
pack .top.cmd -side left -fill x -expand true

bind .top.cmd &amp<Return&amp> Run
focus .top.cmd

menubutton .mb -text Server -menu .mb.menu
pack .mb -padx 10 -pady 10

set m [menu .mb.menu -tearoff 1]
$m add radio -label server1 -variable server -value server1.address.edu -command Run
$m add radio -label server2 -variable server -value server2.address.edu -command Run
$m add radio -label server3 -variable server -value server3.address.edu -command Run
$m add radio -label server4 -variable server -value server4.address.edu -command Run
$m add radio -label server5 -variable server -value server5.address.edu -command Run

proc Run { } {
    global server
    exec rdesktop -u &amp<user_name&amp> -p &amp<password&amp> -g 1280x800 -x b $server

All you need to do is plugin "real" values for the server and addresses. You can also auto-login by giving values for the username and password (may also want to change the geometry of the window unless you have a big screen).


I also have bash aliases for these, but that's a different post...