我有一个rake任务运行,代码很多。最后,我需要使用sftp和ssh来做一些事情。目前我无法将其自动化。有没有办法传递给标准输出?如何将变量从ruby传递到sh命令
这似乎是一个简单的问题,但我无法找到答案的任何地方
#some ruby code
#more ruby code
sh "sftp [email protected]" #this opens the sftp console
sh "put file" #this doesn't get run until sftp is exited
sh "put another_file" #neither does this
#more ruby code
sh "ssh host" # opens the ssh console
sh "some_action_on_host" # this doesn't get run until ssh is exited
我知道会有用红宝石做SFTP和SSH的方式,但最好我只是希望能够管变量和命令进入控制台
试图通过命令行驱动SSH会话比使用[Net :: SSH]更多的工作(http://net-ssh.github.com/ssh/v2/ api/index.html)模块,因为终端和命令行的交互性,除非您一次发送单个命令。 Net :: SSH提供了相当多的控制权。 –