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 2021 - online Python 3 training - see ((here)).

Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7.
We can now offer tailored online training - small groups, real tutors - works really well for groups of 4 to 14 delegates. Anywhere in the world; course language English.

Please ask about private 'maintenance' training for Python 2, Tcl, Perl, PHP, Lua, etc.
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 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., 2022: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: • WEB: • SKYPE: wellho