0

Currently I am trying to automate a process between to computers, and one thing that needs to happen is a file transfer. For whatever reason, this line can't properly output the command I need it to.

for path in filePaths :
    os.system('scp Host@host.IP:' + path +  ' /save/file/here')

Any and all help is appreciated!

  • I would recommend using [Paramiko](https://stackoverflow.com/questions/250283/how-to-scp-in-python) – RightmireM Oct 18 '19 at 17:16
  • 1
    "can't properly output" is not enough information. Please give an example what the output is and what the output should be. What's the value of `path` (and `str(path)`)? – Matthias Oct 18 '19 at 17:16
  • I've looked into using Paramiko, but for whatever reason I simply cannot install it on my device (It's an SBC called the Khadas VIM3). When I say that the line "can't properly output," I mean that the intended output doesn't happen. It seems to cut the command at the point where the ```+ path +``` part is. – Miguel Alatorre Oct 22 '19 at 22:21

1 Answers1

0

Probably something to do with spaces in path? Maybe try:

os.system('"scp {}@{}:{} {}"'.format(host, host_ip, path, save_path))
it's-yer-boy-chet
  • 1,917
  • 2
  • 12
  • 21
  • And what is the difference concerning the spaces you mentioned? The resulting string will be the same. – Matthias Oct 18 '19 at 17:18
  • I tried this out and this is generally what I get: ```scp host@host.IP.address:/path/to/remote/file sh: 2: /stated/local/path: not found``` – Miguel Alatorre Oct 22 '19 at 22:16