diff options
| author | Adam Olech <nddr89@gmail.com> | 2021-06-24 13:01:46 +0200 |
|---|---|---|
| committer | Adam Olech <nddr89@gmail.com> | 2021-06-24 13:01:46 +0200 |
| commit | 680f65e237d6000499d0d1a7c83a79e644b52579 (patch) | |
| tree | 61ac7296bdd43e1c97207eddcb9e9e3002450577 | |
| parent | 7d50d92d9bb9a63ddafe175ce7a4ec92ba5b6cf1 (diff) | |
Pipe find output to tar standard input
| -rwxr-xr-x | tar_over_paramiko.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/tar_over_paramiko.py b/tar_over_paramiko.py index 0801478..fd7dbc1 100755 --- a/tar_over_paramiko.py +++ b/tar_over_paramiko.py @@ -20,8 +20,7 @@ ssh.connect( pkey=key, ) -tarlist = 'tarlist.txt' -find_cmd = 'find {} -type f > {}'.format(sys.argv[4], tarlist) +find_cmd = 'find {} -type f'.format(sys.argv[4]) stdin, stdout, stderr = ssh.exec_command('sh') stdin.write(find_cmd) @@ -29,17 +28,22 @@ stdin.write(find_cmd) stdin.flush() stdin.channel.shutdown_write() +paths = [] + for l in stdout: - print('[FIND STDOUT]\t{}'.format(l.strip('\n'))) + paths.append(l.strip('\n')) + print('[FIND STDOUT]\t{}'.format(paths[-1])) for l in stderr: - print('[FIND STDOUT]\t{}'.format(l.strip('\n'))) + print('[FIND STDERR]\t{}'.format(l.strip('\n'))) -stdin, stdout, stderr = ssh.exec_command('tar cf - -T {}'.format(tarlist)) +stdin, stdout, stderr = ssh.exec_command('tar cf - -T -') stderr_lines = 0 stdout_lines = 0 stdout_type = None +stdin.write("\n".join(paths)) + stdin.flush() stdin.channel.shutdown_write() |
