通过scp实现vps控制没有*IP的localhost

RT,代码也很简单:

本地机上起一个进程如下(test1.sh):

#!/bin/sh
while true
do
   sleep 2
   rm -rf helloworld*
   scp -P 28466 root@138.128.209.211:~/helloworld ~/axe/
   if [ $? -eq 0 ];then
       while read line
           do
           $line
       done < ~/axe/helloworld >>~/axe/helloworld.result
fi
   scp -P 28466 helloworld.result root@138.128.209.211:~/
done

VPS上执行命令的脚本(test2.sh):

#!/bin/sh
echo $1 > helloworld
sleep 5
while read line
  do
    echo $line
  done < helloworld.result

VPS上执行命令如图所示:

 
原文地址:https://www.cnblogs.com/axeprpr/p/5128928.html