expect java_expect命令
expect是一個免費的編程工具語言,用來實現(xiàn)自動和交互式任務進行通信,而無需人的干預。
系統(tǒng)信息:
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
安裝expect
yum -y install expect
測試shell腳本,通過ssh登錄
#!/bin/bash
password="wei123"
expect <
set timeout 10
spawn ssh root@192.168.1.105
expect {
"Are you sure you want to continue connecting (yes/no)?" {send "yes\r";exp_continue}
"password:" {send "${password}\r"}
}
expect "]#"
send "exit\r"
expect eof
EOF
exit 0
轉(zhuǎn)載至鏈接:https://my.oschina.net/bobwei/blog/1861236
總結(jié)
以上是生活随笔為你收集整理的expect java_expect命令的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: SpringBoot项目 整合 Jack
- 下一篇: 已知数组存放一批QQ号码,QQ号码最长为