so the last attempt was a learning process, if you tried it you may have
had *very* hit and miss success, plus general weirdness, the script i
have attached is a little better, i woke up this morning thinking, hmm,
i should not learn at other peoples expence and perhaps i should give a
second effort, it was late after all, so, here is an expect script that
opens 3 xterms, runs telnets, and exits, while leaving the telnets open
- xterm -e would have been easier :)
darrrell dupas
[EMAIL PROTECTED]
#!/usr/bin/expect --
# try this
proc open_xterm {} {
global xterm_spawnid
global shell
spawn -pty
stty raw -echo < $spawn_out(slave,name)
regexp ".*(.)(.)" $spawn_out(slave,name) dummy c1 c2
if {[string compare $c1 "/"] == 0} {
set c1 "0"
}
exec xterm -S$c1$c2$spawn_out(slave,fd) &
close -slave
set xterm_spawnid $spawn_id
set xterm_pty $spawn_out(slave,name)
expect "\n"
spawn "$shell"
}
#open_telnet procedure is dependant on xterm_spawnid -- should do a check
proc open_telnet { hostname loginname password } {
global xterm_spawnid
#spawn "telnet"
spawn "telnet"
set telnet_spawnid $spawn_id
expect "telnet>"
send -s "open $hostname\r"
expect {
"login:" { send -s "$loginname\r" }
}
expect {
"assword:" { send -s "$password\r" }
}
interact -u xterm_spawnid
}
set send_slow { 1 .001 }
set prompt "(%|#|\\\$)"
set shell $env(SHELL)
set xterm_spawnid 0
set fork_pid [fork]
if { $fork_pid == 0 } {
disconnect
open_xterm
open_telnet localhost mp3 mp3
} else {
set fork_pid [fork]
if { $fork_pid == 0 } {
disconnect
open_xterm
open_telnet localhost ddupas lighter
} else {
set fork_pid [fork]
if { $fork_pid == 0 } {
disconnect
open_xterm
open_telnet localhost bad bad
}
}
}
exit