0

I'm trying to copy directory content from MachineA to MachineB. MachineA is CentOS and MachineB is Windows7 (with ssh server installed and working) Since I want to copy directory content I have to use globbing, thus need to call subprocess using shell=True

Code:

scp_cmd = f'scp -v -i ~/ssh_key.pem {SSH_OPTIONS} {src_tests_path}/*'.split()
dst_path = f'{user}@{vm_address}:\"{scripts_path}\"'
scp_cmd += [dst_path]
_logger.info(f"Run scp command: {' '.join(scp_cmd)}")
subprocess.check_output(scp_cmd, shell=True)

But looks like scp "think" I'm passing wrong parameters, since I've got following error:

2019-08-22 14:31:58| INFO    | comet.io.windows_job          | Run scp command: scp -v -i ~/ssh_key.pem -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no testcomplete_smb_tests/* win7@<IP>:"/Users/win7/Documents/TestComplete 14 Projects/VastSMBProject/VastSMBProject/Script"
usage: scp [-12346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]
           [-l limit] [-o ssh_option] [-P port] [-S program]
           [[user@]host1:]file1 ... [[user@]host2:]file2
E: subprocess.CalledProcessError: Command '['scp', '-v', '-i', '~/ssh_key.pem', '-q', '-o', 'UserKnownHostsFile=/dev/null', '-o', 'StrictHostKeyChecking=no', 'testcomplete_smb_tests/*', 'win7@<IP>:"/Users/win7/Documents/TestComplete 14 Projects/VastSMBProject/VastSMBProject/Script"']' returned non-zero exit status 1., Test: <pysrc/tests/comet/io_agent.py:test_windows_client>

Any guess what went wrong here? Thanks for help.

Samuel
  • 3,631
  • 5
  • 37
  • 71

0 Answers0