注意:对 Pramiko 等模块不感兴趣

我正在尝试在远程服务器上保存一些二进制数据而不创建本地文件。

作为一项测试,我从文件中读取,但后来我用数据馈送替换它:

ps = subprocess.Popen(['cat', "/delta/ftp/GSM.PRICINT_TBL.dmp"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) 

下一步我想将数据 ssh 到远程服务器
ssh = subprocess.Popen(["ssh", '-XC', '-c', 'blowfish-cbc,arcfour', 'deltadmin@archiveserver', 'echo - >/tmp/test.log'], 
                                shell=False, 
                                stdin = ps.stdout, 
                                stdout=subprocess.PIPE, 
                                stderr=subprocess.PIPE) 
        result = ssh.stdout.readlines() 
        if result == []: 
            error = ssh.stderr.readlines() 
            print >>sys.stderr, "ERROR: %s" % error 
        else: 
            print result 

我用'-'所以 cat可以接受标准输入。
预期结果是 /tmp/test.log 中的数据但我只看到

'-\n'



知道如何使它工作吗?

请您参考如下方法:

我想通了:

echo 'test'|ssh -XC -c blowfish-cbc,arcfour bicadmin@nitarchive -T 'gzip - >/tmp/test.gz' 

然后在远程服务器上:
 zcat /tmp/test.gz 
test 

对于 cat重定向后我们需要空间:
cat - > /tmp/test.txt 


评论关闭
IT序号网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!