红联Linux门户
Linux帮助

ruby linux连接windows执行dos命令

发布时间:2017-03-31 11:39:32来源:linux网站作者:Fithon
在整个开发流程中,gitlab-runner-ci是搭建在linux下。web自动化是在windows下面进行的。
如果ci构建完版本、部署完后,需要触发启动自动化执行。
 
那么我们需要在部署完后在linux下再调用win下自动化启动脚本。这样就做到提交代码后,编译、单元测试、覆盖率、打包、系统测试无人干预的全自动化处理。
 
1、启用win下telnet服务。(开启方法略)
2、使用ruby net-telnet包实现如下:
require 'net/telnet'
localhost = '172.17.x.xx'
userName = 'shenxxxxxx'
passWD = 'shenxxxxxx'
host = Net::Telnet::new(
"Host"       => localhost,
"Prompt"=> /C:.*>/)
host.login(userName, passWD) { |c| print c }
host.cmd("dir") { |c| print c }
host.close
 
执行结果如下:
ruby linux连接windows执行dos命令
 
本文永久更新地址:http://www.linuxdiyf.com/linux/29628.html