8

Assumption is, this is the script

#!/usr/bin/expect
set a "__test__"

i would like to create a loop inside this script so it can print the value for

 $a

with the a number infront of it based on the loop.

so if i wanted it to loop 3 times.. end product would become:

 1:__test__
 2:__test__
 3:__test__
2
  • 2
    How is this relevant to python tag? Commented Aug 23, 2013 at 21:56
  • @alecxe, well python seems to be a native linux program that works inside the terminal, so i thought it was related Commented Aug 23, 2013 at 21:57

1 Answer 1

9

You can use for

#!/usr/bin/expect
set a "__test__"
for {set x 0} {$x<3} {incr x} {
   puts "$x:$a"
}

See more info in tcl commands because expect is an extension to tcl language.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.