ssh 到服務器沒有問題,一旦spawn su - root后,就一直停留在輸入密碼位置,好像“send "system\r”沒有送過去,是什么原因。
代碼如下
#! /usr/bin/expect
set timeout 10
spawn ssh [email protected]
expect "*assword:" { send "l*kj@19\r" }
spawn su - root
expect "密碼*" { send "system\r"}
send "pwd\r"
interact
錯誤如下:
[ladmin@localhost ~]$ spawn su - root
密碼:
su: 認證失敗
uj5u.com熱心網友回復:
使用的作業系統是Redhat7.5、Redhat6.7uj5u.com熱心網友回復:
已經解決,
#! /usr/bin/expect
set timeout 10
spawn ssh [email protected]
expect "*assword:" { send "l*kj@19\r" }
send "su - root\r"
expect "密碼*" { send "system\r"}
send "pwd\r"
interact
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/26098.html
標籤:內核源代碼研究區
上一篇:xftp服務器界面檔案名消失
下一篇:求幫助!!!
