我的期望脚本旨在在联系9k上执行一些“显示”命令。我已经在我的期望脚本中定义了密码,并且我担心明文密码。我想在执行脚本时提示用户输入密码。
请参见下面的我的期望脚本:
#!/usr/bin/expect
#Defining the variables!
set timeout 300
set USERNAME "User"
set hostip [lindex $argv 0]
set password "cisco"
log_user 1
#log_file -a session_$hostip.log
#send_log "### /START-SSH-SESSION/ IP: $hostip @ [exec date] ###\r"
spawn ssh -q -o StrictHostKeyChecking=no $USERNAME@$hostip
expect "Password:"
send "$password\r"
expect "*?#*"
send "terminal length 0\r"
expect "*?#*"
send "show version\r"
expect "*?#*"
send "show module\r"
expect "*?#*"
send "show ip interface brief\r"
expect "*?#*"
send "show interface status\r"
expect "*?#*"
send "show interface description\r"
expect "*?#*"
send "show inventory\r"
expect "*?#*"
send "exit\r"
#send_log "\r### /END-SSH-SESSION/ IP: $hostip @ [exec date] ###\r"
puts "\r\r"