Re: GUI on top of Expect Script

Dukie91191 wrote:
Hi all,
Just to preface this, I am pretty new to Tcl/tk/Expect, but I seem to
be doing OK so far.

My problem is this, I have created an Expect script that logs into a
switch and configures it. It prompts the user for 3 pieces of
information and then it goes off on its merry way, works wonderfully.
Now, in a moment of daring, I started looking at Tcl/Tk to wrap this
script of mine up in a more user friendly GUI, as the script currently
runs from a command line.

expect is an extension to tcl
tk is an extension to tcl

You can use both at the same time and from the same script.

[exec]ing your expect script will make the gui inresponsive
while it is running.

label .lh -text Host:
entry .eh -textvariable ::IP
set ::IP ""
label .lu -text User:
entry .eu -textvariable ::USR
set ::USR ""
label .lp -text Pass:
entry .ep -textvariable ::PASSWD
set ::PASSWD ""

button .b -text Connect -command {ssh_connect $::IP $::USR}
label .ls -textvariable ::STATUS
pack -side left .lh .eh .lu .eu .lp .ep .b .ls
set ::STAT -/-

proc ssh_connect {ip usr} {
if {$ip == "" } {
set ::STAT NO_IP
if {$usr == "" } {
set ::status trying:$ip
spawn ssh ${usr}@$host
set :curr_spid $spawn_id
expect "assword: " {
set ::STAT "sending password"
exp_send "$::PASSWD\r"

vwait forever