1

folks,

I faced an issue unzipping files via SSH using Python Paramiko library.I download a .zip file using wget and try to unzip it with this command:

client = SSHClient()
client.set_missing_host_key_policy(AutoAddPolicy())
client.connect(hostname=host,port=port, username=user, password=psw)
stdin,stdout,stderr = client.exec_command('unzip /path/to/file.zip', get_pty=True)

for line in iter(stdout.readline, ""):
    print(line, end="")

it finds a file tries to unzip it and hangs..

Archive:  /path/to/file.zip

Could you help me?

mike
  • 101
  • 1
  • 15
  • Why `get_pty=True`? What does your code do after `exec_command`? How do you detect that it hangs? – Martin Prikryl Apr 25 '20 at 17:45
  • @MartinPrikryl to get a pseudo-terminal so I could see what is happening there. It does nothing after it executes this command. I claim that it hangs because it outputs```Archive: /path/to/file.zip ``` and then nothing happens program is still running but that all.. – mike Apr 25 '20 at 18:06
  • edited my post to make things more clear for you guys :) – mike Apr 25 '20 at 18:10
  • How do you know what it's outputting? Do you have some code that reads from stdout or stderr? Please [edit] your question to include that code. – Kenster Apr 26 '20 at 01:24
  • 1
    I do not see how `get_pty=True` alone gets you any output. You must be reading it first. Where's your code for that? + Have you seen this? [Paramiko ssh die/hang with big output](https://stackoverflow.com/q/31625788/850848) – Martin Prikryl Apr 26 '20 at 06:45
  • @MartinPrikryl sorry my bad, edited my question – mike Apr 26 '20 at 09:57
  • So did you follow the link I've posted in my previous comment? – Martin Prikryl Apr 26 '20 at 10:08
  • Hi, yea, now it works :) thank you @MartinPrikryl ! – mike Apr 26 '20 at 15:25

0 Answers0