How to pass argument in expect through command line in shell script
问题 I am passing argument in expect through command line in shell script I tried this #!/usr/bin/expect -f set arg1 [lindex $argv 0] spawn lockdis -p expect "password:" {send "$arg1\r"} expect "password:" {send "$arg1\r"} expect "$ " but it's not working. Please help me to figure it out. Thanks 回答1: If you want to read from arguments, you can achieve this simply by set username [lindex $argv 0]; set password [lindex $argv 1]; And print it send_user "$username $password" That script will print $ .