原因:
现在代码用远程git管理,但是Linux服务器不能连接外网,只能曲线救国:在本地写代码,然后同步代码到Linux服务器,并发送指令进行编译。
准备工作:
安装expect:
我电脑上已经安装了brew,执行brew install expect
set user embest
set pass ******
set dir ~/Documents/share/application/d20
set appDir ~/Documents/share/application/d20/hs_door_temperature_cpp
set ip 192.168.100.200
set filen ../../hs_door_temperature_cpp
#拷贝源文件
spawn scp -r ${filen} ${user}@${ip}:${dir}
expect "${user}@${ip}'s password:"
send "${pass}\r"
interact
#修改权限
spawn ssh ${user}@${ip} "chmod 777 -R ${appDir}/*"
expect "${user}@${ip}'s password:"
send "${pass}\r"
interact
#编译
spawn ssh ${user}@${ip} "cd ${appDir}; ./auto.sh"
expect "${user}@${ip}'s password:"
send "${pass}\r"
interact
大功告成!