Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
Falt Tolerance for bad connections

Posted by selfism (selfism), 9 February 2005
Hi all,

I am attempting to verify if the commands I send are received correctly on the far end machine. To accomplish this I look for my command to be echoed back to me, in this way I know the remote machine received it perfectly. To test this I am purposely connecting to a remote system that has stty -echo in its bash_profile. My echoing test should fail and activate my "timeout" action. MY PROBLEM is that I keep looping on the "send human" action in my timeout action instead of moving to the next step in my timeout action. I tried removing the exp_continue but then the next command in the cmd_list is run rather than having my original command rerun. I suspect I have a problem with my logic but I am watermelon Tuesday .

My code is as follows, any help would be REALLY appreciated!

foreach cmd $cmd_list {

set bad_echo "0"
send -- "$cmd"

expect {
  timeout
  {
     if {$bad_echo == 0} {
     set $bad_echo "1"
     set send_human {.1 .3 1 .05 2}
     send -h  "$cmd"
     exp_continue
     } elseif {$bad_echo == 1} {
     set bad_echo "2"
     set send_slow {1 1}
     send -s "$cmd"
     exp_continue
     } else {$bad_echo == 3} {
     set report_file [open "$task_dir/report.txt" "WRONLY"]
     puts $report_file "Possible dirty connection to $host, simon says   echoing won't work"
     continue
     }
  }

  eof
  {
     set report_file [open "$task_dir/report.txt" "WRONLY"]
     puts $report_file "Lost connection to $host"
     continue
  }

  -re "$cmd"
   {
      send -- "\r"
   }
}
#EOF expect loop

expect -re "$prompt"

}

interact

}
# end of server foreach loop


*****exp_internal info:
[mux@Indestructible ~]$ send: sending "ps" to { exp9 }

expect: does "" (spawn_id exp9) match regular expression "ps"? no
expect: timed out
send: sending "ps" to { exp9 human_write: avg_arr=0.100000/0.300000  1/shape=1.000000  min=0.0500 00  max=2.000000
}
expect: continuing expect

expect: does "" (spawn_id exp9) match regular expression "ps"? no
expect: timed out
send: sending "ps" to { exp9 human_write: avg_arr=0.100000/0.300000  1/shape=1.000000  min=0.0500 00  max=2.000000
}
expect: continuing expect

expect: does "" (spawn_id exp9) match regular expression "ps"? no
expect: timed out
send: sending "ps" to { exp9 human_write: avg_arr=0.100000/0.300000  1/shape=1.000000  min=0.0500 00  max=2.000000
}





Posted by admin (Graham Ellis), 9 February 2005
I think that

set $bad_echo "1"

should read

set bad_echo "1"


Posted by selfism (selfism), 10 February 2005
I am sorry for cluttering the boards with stupid oversights. I am not offended if you delete my postings.

Thank you, it worked.

Posted by admin (Graham Ellis), 10 February 2005
Don't worry about it - we all do things like that  

- Graham



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho