您好,登录后才能下订单哦!
1.脚本名称demo.sh
#!/bin/bash
yum -y install expect
expect -c "
spawn scp -r /Users/yunshuodeng/Work/mydocker/app/provider/power-dubbo-provider-1.0-SNAPSHOT.jar root@192.168.2.248:$1
expect {
\"*assword\"
{
set timeout 300;
send \"hntx123456\r\";
}
\"yes/no\"
{
send \"yes\r\"; exp_continue;}
}
expect eof"
expect -c "
spawn scp -r /Users/yunshuodeng/Work/mydocker/app/consumer/power-dubbo-consumer-1.0-SNAPSHOT.jar root@192.168.2.248:$1
expect {
\"*assword\"
{
set timeout 300;
send \"hntx123456\r\";
}
\"yes/no\"
{
send \"yes\r\"; exp_continue;}
}
expect eof"
expect -c "
spawn scp -r /Users/yunshuodeng/Work/mydocker/app/consumer/power-dubbo-api-1.0-SNAPSHOT.jar root@192.168.2.248:$1
expect {
\"*assword\"
{
set timeout 300;
send \"hntx123456\r\";
}
\"yes/no\"
{
send \"yes\r\"; exp_continue;}
}
expect eof"
expect -c "
spawn ssh root@192.168.2.248
expect {
\"*assword\"
{
set timeout 300;
send \"密码\r\";
}
\"yes/no\"
{
send \"yes\r\"; exp_continue;
}
}
expect \"*#\"
send \"cd $1\r\"
expect \"*#\"
send \"./$2\r\"
expect \"*#\"
send \"exit\r\"
expect eof"
echo "success"
2.执行shell
./demo.sh /home/demo mymkdir.sh
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。