[问题] 用expecet脚本传入含有"$"的密码

楼主: jacobcan118 (jacobcan118)   2016-07-28 11:29:23
请问各位我要如何借由expect自动登入从参数送登入密码含有"$" 钱符号的密码
我用同一个脚本自动登入没有问题可是当机器密码含有"$"时他会试着登入三次之后送出登入错误的讯息
我用debug去看发现如密码含有"$" expect自动加了"{", "}", 有试着在密码前后加上单引号或双引号 不过结果都一样
谢谢
$/usr/bin/expect -d expect.sh 10.1.1.10 1234\$123
$/usr/bin/expect -d expect.sh 10.1.1.10 "1234\$123"
$/usr/bin/expect -d expect.sh 10.1.1.10 '1234\$123'
执行结果
expect: does "\r\n" (spawn_id exp6) match glob pattern "*?assword:*"? no
"*yes/no*"? no
Permission denied, please try again.
root@10.1.1.10's password:
expect: does "\r\nPermission denied, please try again.\r\r\nroot@10.1.1.10's password: " (spawn_id exp6) match glob pattern "*?assword:*"? yes
expect: set expect_out(0,string) "\r\nPermission denied, please try again.\r\r\nroot@10.1.1.10's password: "
expect: set expect_out(spawn_id) "exp6"
expect: set expect_out(buffer) "\r\nPermission denied, please try again.\r\r\nroot@10.1.1.10's password: "
send: sending "{1234$123}\r" to { exp6 }
expect: continuing expect
作者: yvb   2016-07-28 23:30:00
问题在于你 expect.sh 中, 怎么读参数的. 可能用错方法了.
楼主: jacobcan118 (jacobcan118)   2016-07-29 01:28:00
我是用 set password [ lrange $argv 1 1 ] 取的参数密码
作者: yvb   2016-07-29 19:04:00
(1) set password [lindex $argv 1](2) lassign $argv arg0 password arg2 ...

Links booklink

Contact Us: admin [ a t ] ucptt.com