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))
Expect script that gets into loop

Posted by manisri (manisri), 21 March 2003
Hi, i am running the below script under WindowsNT.
Here "ds" expects from user.(i want to make it non-interactice using script). But following script  goes into loop even i am giving input("dsreddy") only once .  plz help me  why it is going into loop.?

exp_internal 1
set exp_nt_debug 1
set timeout 60
spawn ds
while 1 {
expect {
        "dsreddy" {  
        #puts "$expect_out(0,string)"      
                    set str $expect_out(0,string)
                    send "$str\r"
                                   
                    }
         "msreddy"  {
                   send "Good one\r"}
            eof exit
    }

  }


Posted by admin (Graham Ellis), 21 March 2003
You're going into the loop because it's there in your code and will always be reached, and the condition you give ("1") is always true.

Are you telling us that it remains in the loop (i.e. keeps looping) when you don't expect it to?

The ds program that you have spawned starts off by sending us the string "dsreddy" which you ECHO RIGHT BACK TO IT.  Perhaps this is right, but it seems a bit peculiar - I might guess that you want to puts (to stdout) rather than send (to ds) the string.



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