The code below
#! The/usr/bin/expect
Set the timeout of 10
Spawn SSH [email protected]
Expect "* assword:" {send 19 \ r "" l * kj @}
Spawn su - root
Expect "password *" {send system \ "r"}
Send "the PWD \ r"
Interact
Error is as follows:
[ladmin @ localhost ~] $spawn su - root
Password:
Su: authentication failed
CodePudding user response:
Use of the operating system is Redhat7.5 Redhat6.7CodePudding user response:
Has been resolved,#! The/usr/bin/expect
Set the timeout of 10
Spawn SSH [email protected]
Expect "* assword:" {send 19 \ r "" l * kj @}
send "su - root \ r"
Expect "password *" {send system \ "r"}
Send "the PWD \ r"
interact