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.
starting a background process

Posted by shafa.fahad (FahaD), 31 October 2006

I would like to know how to spawn a back process in Expect/TCL. A piece
of code would be helpful....

I have a script which logs into remote system and does serious of
operation and bring out the output. find below the simple script for

#!/usr/bin/expect -f
set prompt "(%|#|\\$|%]|\\):|>) $"
spawn ssh k...@
expect {
password {
            send_user "Enter password for $cStruct(admin):"
            stty -echo
            expect_user -re "(.*)\n" {set pStruct(passwd)
            send "$pStruct(passwd)\r"
            stty echo
-re $prompt {
           send_user "Please wait the operation is being performed"
           log_user 0
           send "somecommand\r"
           expect -re $prompt
           send "somecommand\r"
           expect -re $prompt
           send "somecommand\r"
           expect -re $prompt
           send "somecommand\r"
           expect -re $prompt
           send "somecommand\r"
           expect -re $prompt
           send "somecommand\r"
           expect -re $prompt
           set result $expect_out(buffer)
           puts stdout $result
           send "exit\r"


In the above operation, after user enters the password he will get the
message "please wait the operation is being performed" and then because
of log_user 0 user wont get to see what command is fired and after some
time he will get the result.

My requirement is to display "please wait while the operation is being
performed" to be dynamic and hence keeps blinking till the operation is

Any help would be apprecited.

Thanks in advance

Posted by admin (Graham Ellis), 1 November 2006
You could spawn a shell and background it via there, but it seems a bit obscure.   Also have a look at expect_after which may allow you to return if there isn't a match yet back if the real expression your looking for hasn't appeared.   Sorry the reply is a bit patch today - I'm away from base and books!

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