RSS订阅个人笔记
你的位置:首页 » shell脚本 » 正文

expect用法

选择字号: 超大 标准 发布时间:2019年12月03日 | 作者:admin | 0个评论 | 1629人浏览

#!/bin/bash
rpm -qa|grep expect >/dev/null|| yum -y install expect
passwd=123456
expect -c " 
spawn scp /root/test.txt root@192.168.16.100:/home/
expect {
 \"(yes/no)?\" {send \"yes\n\"; expect \"*assword:\" {send \"$passwd\n\"}}
 \"*assword:\" {send \"$passwd\n\"}
 }
expect eof



#!/usr/bin/expect
set timeout 30
spawn ssh root@192.168.16.100
#expect "*(yes/no)"
#send "yes\r"
expect "*password:"
send "123456\r"
expect "#"
send "df -lh\r"
send "ls /home\r"
expect "#"
interact


标签:

欢迎加QQ:2908190019

猜你喜欢

额 本文暂时没人评论 来添加一个吧

发表评论

必填

选填

选填

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。