Re: Need Help in Loop Foreach



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



Relevant Pages

  • Re: my KDF vs dictionary attacks
    ... tell me mr Herring are you a programmer? ... there are 2 possible loops and 2 possible variations of each ... the first loop is a do until loop ... loop and then increment the number and counter n times within the loop ...
    (sci.crypt)
  • Re: ntdll.dll shown to take 30% in profiler
    ... I even tried it in several variations. ... In all cases the performance was far worse than with creating and destroying ... each one in another loop. ... Even in the best case however, still a significant percentage of CPU time is ...
    (borland.public.delphi.language.basm)
  • Re: simple lisp function
    ... > this simple function i'm trying to write is giving me headaches! ... ;; More variations on variations ... (defun variations (obj list) ... (loop for i from 0 to (length list) ...
    (comp.lang.lisp)