Re: Need Help in Loop Foreach
- From: claird@xxxxxxxxx (Cameron Laird)
- Date: Mon, 25 Sep 2006 21:19:51 +0000
In article <ef99kb$j8f$1@xxxxxxxxxxxxxxxxxxxx>, Henr <mlenf@xxxxxxxxx> wrote:
Hi, I'm new to Expect/TCL can someone help me out with this simple script.
I'd like to insert a loop, in such a way that it reads all the "System ID"
from a file called "SysIDList"
# cat SysIDList
8
9
10
#!/usr/local/bin/expect
# Query all the systems status by inputting the SystemIDs on Expect Script
set env(HOME);
log_file $env(HOME)/getsys-out3;
spawn sys_monitor;
expect
"**********************************************************************";
expect "* SYSMonitor
*";
expect
"**********************************************************************";
expect " SYSMonitor-> ";
send "QUERY\r";
expect " ======================================";
expect " System ID :";
send "8\r"; # This is where the loop would be needed.
expect " SYSMonitor-> ";
send "exit\r";
log_file;
I don't know. I *think* you're asking for
...
expect \
"**********************************************************************"
foreach ID in {8 9 10} {
expect " SYSMonitor-> "
send "QUERY\r"
expect " ======================================"
expect " System ID :"
send "$ID\r" # This is where the loop would be needed.
}
expect " SYSMonitor-> "
send "exit\r"
log_file
Try that.
If you want to read the list from a file, you might write instead
...
foreach ID in [exec cat SysIDList] {
...
Your terminating semicolons add no value, incidentally.
Still other variations might eventually give you more satisfaction.
Making these changes will be a good start, though.
.
- References:
- Need Help in Loop Foreach
- From: Henr
- Need Help in Loop Foreach
- Prev by Date: Re: is tcl/tk dying out?!
- Next by Date: Re: is tcl/tk dying out?!
- Previous by thread: Re: Need Help in Loop Foreach
- Next by thread: Re: Need Help in Loop Foreach
- Index(es):
Relevant Pages
|