def scp(srchost=None, srcpath=None, dsthost=None, dstpath=None, user=None, password=None, prompt=None, callback=None, logfile=None): """scp(source, destination, [password]) Copies the file from source to destination. these parameters are strings that are passed directly to the scp command, and should follow the syntax for this command. """ opts = "-q" src = location(srchost, user, srcpath) dst = location(dsthost, user, dstpath) CMD = "%s %s %s '%s' '%s'" % (SCP, SSH_OPTIONS, opts, src, dst) if logfile: logfile.write(CMD+"\n") scp = proctools.spawnpty(CMD, logfile=logfile) if password is not None: escp = SSHExpect(scp) scp.set_callback(callback or escp.death_callback) escp.login(password) discard = escp.read() else: discard = scp.read() es = scp.wait() return es