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