1

終了し続けるという問題に遭遇しましたが、SSHセッションを継続するためのsendステートメントを期待して、なぜそれ以上挿入できなかったのか理解できませんでした???

#!/usr/bin/expect
set timeout 15
set hostname [lindex $argv 0]
set username [lindex $argv 1]
set password [lindex $argv 2]
set enable [lindex $argv 3]
set send_slow {10 .001}
log_user 1

expect -f snmp2.exp 172.28.135.24 localadmin Gr0upM540 z540Mxy3
set configuration /tmp/ntp
set routerlist [open "/tmp/routerlist" "r"]
set logfile [open "/tmp/ntp_config" "w"]


spawn ssh $username@$hostname

expect {
  timeout { send_user "\nFailed to get password prompt\n"; exit 1 }
  eof { send_user "\nSSH failure for $hostname\n"; exit 1 }
  "*#" {}
  "*assword:" {
    send "$password\r"
  }
}

send "/r"

expect {
  "*#" {}
  "*>" {
    send "enable\r"
    expect "*assword"
    send "$enable\r"
    expect "*#"
  }
}

send "exit\r"
send_user "\nSuccessfully changed SNMP password on $hostname\n"
close
4

0 に答える 0