如何在Ruby NET上输入远程目录:SFTP? [英] How to enter a remote directory on Ruby NET:SFTP?
本文介绍了如何在Ruby NET上输入远程目录:SFTP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何输入一个像命令cd这样的目录,从而操作没有路径前缀的远程文件?
How to enter a directory like the command - cd, thus operate remote files without a path prefix ?
这是我目前的代码。
Net::SFTP.start do |sftp|
sftp.rename!(REMOTE_PATH + "latest.zip", REMOTE_PATH + "latest.back.zip")
sftp.upload!("latest.zip", REMOTE_PATH + "latest.zip")
end
我想要:
I would like to have:
sftp.cd REMOTE_PATH
sftp.rename!("latest.zip", "latest.back.zip")
sftp.upload!("latest.zip", "latest.zip")
推荐答案
我找到了一个解决方案,它使用SSH连接。。不起作用。 SFTP路径似乎与SSH路径无关。让我知道你是否有其他选择。
I found a solution, which is use the SSH connect instead.. Not works. SFTP path seems irrelevant to SSH path. Let me know if you have other options.
Net::SSH.start("localhost", "user", "password") do |ssh|
ssh.sftp.upload!("/local/file.tgz", "/remote/file.tgz")
ssh.exec! "cd /some/path && tar xf /remote/file.tgz && rm /remote/file.tgz"
end
这篇关于如何在Ruby NET上输入远程目录:SFTP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文