I use Python Paramiko and scp to perform some operations on remote machines. Some of the machines I'm working on require files to be available locally on their system. When this is the case, I use Paramiko and scp to copy files. For instance:
from paramiko import SSHClient
from scp import SCPClient
ssh = SSHClient()
ssh.load_system_host_keys()
ssh.connect('192.168.100.1')
scp = SCPClient(ssh.get_transport())
scp.put('localfile', 'remote file')
scp.close()
ssh.close()
My question is, how can I check if a local file exists on the remote computer before I try scp?
I would like to try and use Python commands where possible, i.e. not bash
source
share