通过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上执行命令如图所示:
By.徐晓1024