- 论坛徽章:
- 0
|
各位。目前正在学习expect,遇到一问题:(是网络上的一个教程《揭开 Expect 的神秘面纱》,主要实现改变shell)
#!/usr/bin/expect
set timeout 5
set user [lindex $argv 0]
spawn chsh $user
expect -re "\[(.*)]:"
if {$expect_out(1,string) != "/bin/tcsh"}{
send "/bin/tcsh " }
send " "
expect eof
exit
但是运行报错:
Enter the new value, or press ENTER for the default
Login Shell [/bin/bash]: can't read "expect_out(1,string)": no such variable
while executing
"if {$expect_out(1,string)!="/bin/tcsh"} {
send "/bin/tcsh "}"
(file "test.exp" line 7)
什么意思?
谢谢
[ 本帖最后由 roong 于 2008-12-2 10:25 编辑 ] |
|