0

I have a problem for several days. On my Raspberry Pi I go to the terminal for executing the following command:

scp user@subdomain.server.com:/home/path/to/file/test.py /home/pi/update/test.py

It works fine and copies the file from the server without password (because of ssh-keys) to my local machine.

BUT: I have to do exactly the same within a python script:

import os
cmd = 'scp user@subdomain.server.com:/home/path/to/file/test.py /home/pi/update/test.py'
os.system(cmd)

This doesn't work giving an error

ssh: Could not resolve hostname subdomain.server.com: Temporary failure in name resolution

Why do I get this message and especially how can I solve it? Does anyone give an advice, please? I don't understand it ...

hmp
  • 11
  • 2
  • Does this answer your question? [How to scp in Python?](https://stackoverflow.com/questions/250283/how-to-scp-in-python) – Alexey S. Larionov Mar 28 '22 at 09:41
  • Thank you, but unfortunately it doesn't work. I tried different things with paramiko, pssh, scp, ... and all won't work. – hmp Mar 28 '22 at 14:49
  • One problem is that my "pip-installed"-modules can be found locally in /home/pi/.local/lib/python3.7/site-packages but the import in my python script can't found them. So I copied them to the script folder ... that helped. But I can't get any connection. – hmp Mar 28 '22 at 14:56

0 Answers0