#!/usr/local/bin/expect -- # connect - front end program for kibitz2 allowing connection to spec. # Author: Mark Lumsden, McMaster University exp_version -exit 5.0 set argt [lindex $argv 0] set test2 "" set test4 [string compare $argt $test2] set run [lrange $argv 0 end] stty -echo raw log_user 0 set id1 [spawn $env(SHELL)] set name [exec whoami] puts "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" puts "CONNECT V1.0\r" puts "Mark Lumsden\r" puts "McMaster University\r\n" if $test4==0 { if {(![file exists /tmp/pid.out])||(![file exists /tmp/fifo.out])} { puts "Fourc not running under connect \r" puts "Nothing to connect to \r" exit } if [file exists /tmp/rlogfile.1] { puts "Another user already remotely connected\r" puts "Cannot connect" exit } set pidfile [open /tmp/pid.out r] gets $pidfile pid gets $pidfile user close $pidfile set root_name "root" set name_tst1 [string compare $name $user] set name_tst2 [string compare $name $root_name] if {($name_tst1 != 0) && ($name_tst2 != 0)} { puts "You are not the user of the connect process \r" puts "To connect, enter the password for $user \r\n" send_user "Password for $user:" set timeout 10 expect_user { timeout { send_user "\nSorry\n" exit } -re "(.*)\r" { set password $expect_out(1,string) } } send_user "\n" stty echo set timeout -1 log_user 0 spawn su $user expect "assword:" send "$password\r\n" expect { "incorrect" { puts "Password incorrect \r" puts "Exiting \r" exit } ":/" { puts "\r" } } } puts "Connecting \r" spawn kibitz2 -$pid interact exit } if $test4!=0 { if [file exists /tmp/llogfile.1] { puts "Connect connect is already running once\r" puts "Cannot run it twice\r" exit } spawn kibitz2 $name $run interact exit }