Training, Open Source computer languages

This is page http://www.wellho.net/forum/The-Tcl- ... guage/starting-a-background-process.html

Our email: info@wellho.net • Phone: 01144 1225 708225

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

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

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
reference...

#!/usr/bin/expect -f
set prompt "(%|#|\\$|%]|\\):|>) $"
spawn ssh k...@10.67.45.80
expect {
password {
            send_user "Enter password for $cStruct(admin):"
            stty -echo
            expect_user -re "(.*)\n" {set pStruct(passwd)
$expect_out(buffer)}
            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
complete.

Any help would be apprecited.

Thanks in advance
Fahad



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 www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

© 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