[paramiko] paramiko + tarfile
José Arthur Benetasso Villanova
jose.arthur at gmail.com
Sat Jun 27 06:48:40 PDT 2009
Hi all.
I'm trying to simulate the command 'tar -czf - . | ssh root at 172.16.0.2 tar
-xzf -' with paramiko.
Unfortunately,I'm missing something. Here my code:
###############################################################################
import tarfile
import paramiko
client = paramiko.SSHClient()
client.load_system_host_keys()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(
'172.16.0.2',
username='root',
password='123456',
timeout=60)
ssh_stdin, ssh_stdout, ssh_stderr = client.exec_command('tar -C /tmp/x -xzf
-')
tfile = tarfile.open(mode='w|gz', fileobj=ssh_stdin)
tfile.add('.')
tfile.close()
client.close()
###############################################################################
Sometimes, files doesn't appear on destination. I'm thinking the problem is
the flow control of ssh_stdin.
Does someone did a similar code? How can I control stdin to not loss data
(if it is a problem).
Thanks in advance.
--
José Arthur Benetasso Villanova
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.lag.net/pipermail/paramiko/attachments/20090627/3d546a36/attachment.htm
More information about the paramiko
mailing list