expect自动化

1206人浏览 / 0人评论

expect自动化

1、登陆主机脚本

[root@gmw-jump-server ~]# cat 1.sh
#!/bin/bash
file=$1
expect <<EOF
spawn ssh liangzeyu@192.168.31.12
expect {
	"*yes/no" {send "yes\r"}
	"*password:" {send "mimaxxsw\r"}
}
expect -re ".*\[\$#\]"
send "df -h\r"
expect -re ".*\[\$#\]"
send "aplay $1\r"
expect -re ".*\[\$#\]"
send "exit\r"
EOF

全部评论