Expect argument handling
Question
I'd like to create an expect script that connects to the server via telnet and does some authorisation. I have a problem with using script parameters though. Based on man I expected this to work:
#!/usr/bin/expect -f
spawn telnet $argv1 5038
...
Unfortunately I get back can't read "argv1": no such variable
. How can make this work?
Solution
$argv
is a Tcl list holding the command line parameters, indexed beginning from 0. You want:
[lindex $argv 0]
OTHER TIPS
I got a similar error, can't read "argv0": no such variable
, when I tried to use $argv0 in a proc. The solution was to explicitly access it from the global namespace by using $::argv0
.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow