重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

shell脚本远程连接服务器并执行指定的shell脚本-创新互联

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

创新互联www.cdcxhl.cn,专业提供香港、美国云服务器,动态BGP最优骨干路由自动选择,持续稳定高效的网络助力业务部署。公司持有工信部办法的idc、isp许可证, 机房独有T级流量清洗系统配攻击溯源,准确进行流量调度,确保服务器高可用性。佳节活动现已开启,新人活动云服务器买多久送多久。


网页名称:shell脚本远程连接服务器并执行指定的shell脚本-创新互联
转载来于:http://cqcxhl.com/article/csgsoi.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP