LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   expect script - for argument loop ? (https://www.linuxquestions.org/questions/linux-software-2/expect-script-for-argument-loop-754626/)

nilleso 09-12-2009 08:16 AM

expect script - for argument loop ?
 
in ksh/bash I often use a for loop as in the following example:
Code:

for name in bob jim jacobo henric;do
print hello $name
done

How can I do the same for loop in an expect script?

TIA!!
cheers :)

colucix 09-12-2009 09:06 AM

Quote:

Originally Posted by nilleso (Post 3679935)
How can I do the same for loop in an expect script?

It depends on what do you want to achieve. You can either write a shell script which executes an expect script inside the for loop, passing the name as argument OR write an expect script which uses control flow statements whose syntax is the same as Tcl.

jlinkels 09-13-2009 07:09 AM

Code:

foreach name {bob jim jacobo henric} {
  puts "hello $name"
}

jlinkels

nilleso 09-16-2009 08:51 PM

thanks folks jlinkels solution worked for me. I often embed expect inside of shell scripts but I couldn't get the for loop to work as expected.

cheers :)


All times are GMT -5. The time now is 05:58 AM.