Problems with scp script in Python

Steve D'Aprano steve+python at pearwood.info
Mon Feb 13 09:49:19 EST 2017


On Mon, 13 Feb 2017 11:17 pm, jhlobin at gmail.com wrote:

> I have an SCP script that auto completes just fine from the terminal
> window in Pi.  When I use either subprocess or os to try and have it run
> under Python it does not do the file transfer from Pi to my Ubuntu
> machine.  What am I doing wrong?  Here is the script:

First thing you are doing wrong: you are re-typing the script instead of
copying and pasting it. There's at least one error in your script below: a
missing colon. How many other errors did you make when retyping? There's no
way for us to tell.

Second thing you are doing wrong: keeping the exception traceback a secret
from us. How are we supposed to diagnose the error when we can't see what
the error is?

Even if we wanted to run your code, we can't: we'll get a completely
different error, since we don't have access to your network and user
account.


> from subprocess import call
> cmd='scp -i id_rsa sample.txt jack at 192.168.1.103 /home/jack/pi_data'
> call (cmd.split ())
> 
> Thank you

If there is no exception traceback, is there any output at all?

Again, don't type it from memory, COPY and PASTE the output as you see it,
exactly. If you remove any private information (like a plain text password)
make it obvious that has been removed by replacing it with a string of
asterisks **** .



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list