Suppose that I call my.exp
by
my.exp cmd a b c d ...
I want to pass all the arguments of my.exp to spawn. But I don't find a way to do so. Is there a way to do it with expect? Thanks.
#!/usr/bin/env expect
spawn $argv
...
You'd want to use tcl's argument expansion syntax to do this:
spawn {*}$argv
#!/usr/bin/env expect
log_user 0
puts "Spawning '$argv'"
spawn {*}$argv
expect *foo* { puts "Got: '[string trim $expect_out(buffer)]'" }
$ ./my.exp echo foo bar
Spawning 'echo foo bar'
Got: 'foo bar'