因此,我有一个期望脚本发送到HPE虚拟连接模块以运行show all命令。然而,当我在 “期待” 提示 “ - >”,即时得到一个错误:Linux期望在提示符中预期连字符
bad flag "-> ": must be -glob, -regexp, -exact, -notransfer, -nocase, -i, -indices, -iread, -timestamp, -timeout, -nobrace, or --
while executing
"expect "-> ""
(file "./expect_vc_showall.ziUzpF" line 10)
这里是我的代码:
#!/usr/bin/expect -f
set timeout 60
set ip_hostname [lindex $argv 0];
#log_user 0
spawn ssh [email protected]$ip_hostname
expect {
"*yes/no*" { send "yes\r"; exp_continue }
"*assword:" { send "password123\r" }
}
expect "-> "
send "show all\r"
#log_user 1
expect "-> "
send "exit\r"
我曾尝试使用期望 - “ - > “但那只是让我接受提示然后去世。
这里是提示的样子:
Last login: Thu Jul 27 17:09:28 2017 from 172.16.100.78
-------------------------------------------------------------------------------
HP Virtual Connect Management CLI v4.41
Build: 4.41-6 (r315367) Mar 5 2015 13:59:31
(C) Copyright 2006-2015 Hewlett-Packard Development Company, L.P.
All Rights Reserved
-------------------------------------------------------------------------------
GETTING STARTED:
help : Displays a list of available subcommands
exit : Quits the command shell
? : Displays a list of managed elements for a subcommand
? : Displays detailed help for a command
->
如果只是我一个希望“>”,它死在第一子命令文本。
任何想法如何让这个工作?
谢谢! 乔
2017-07-27
Joe
+0
怎么逃脱它像'\ - >'? –
+0
试过了,它只是把我带到提示。不发送所有节目。 –