#!/usr/bin/expect -- #Note: the file .kermrc has the command "prompt k>>" #111209-remove the ping log_user 0 #============== # READ THE COMMAND LINE # COMMANDS # 1. SETUP FILE PATH AND NAME, /setup/test_setup.txt # 2. SIMULATE- dddd where eac d=0/1 # order of d's is [cdu][rad][tcm][gps][wxt] "crcgw" #============== set argc [llength $argv] # NO CMD LINE ARGS ==>> HELP if { $argc == 0} { set setupfile "$env(DAQSWFOLDER)/setup/su.txt" } else { # SETUP FILE DEFINED set setupfile [lindex $argv 0] ## SEE IF THE SETUP FILE EXISTS if [catch {open $setupfile} sufile] { puts "Setup file open fails, exit 1" exit 1 } else { puts "SETUP FILE $setupfile EXISTS" } } #============== ## READ SETUP FILE FOR IP ADDRESS #============== spawn -noecho getsetupinfo $setupfile "SERIAL HUB IP" expect -re "(\.*)(\r)"; set hubip $expect_out(1,string) send_user "SERIAL HUB IP: $hubip\n" #============== ## READ SETUP FILE FOR PORT NUMBER #============== spawn -noecho getsetupinfo $setupfile "SBD PORT" expect -re "(\.*)(\r)"; set portnumber $expect_out(1,string) send_user "RAD PORT: $portnumber\n" # 111221-remove ping as unnecessary. # START PROCESS spawn kermit set PDS3 $spawn_id set timeout 4 expect { -i PDS3 timeout {"KERMIT FAILS TO OPEN\n"; exit 1} ">>" } ## OPEN THE PORT send "set host $hubip $portnumber\r" expect ">>" send_user "set host $hubip $portnumber\n"; ## FINE TUNING TCP/IP send "set tcp keepalive on 0\r\n" expect ">>" send "set tcp linger 0\r\n" expect ">>" send "set tcp nodelay on\r\n" expect ">>" send "set telnet echo local\r\n" expect ">>" ## CONNECT send "connect\r" expect { "Conn*---" {send_user "SBD MODEM CONNECTED\n"} timeout {send_user "TIMEOUT, NO CONNECT"; exit 1} } set spawn_id $PDS3 interact exit 0