sftp.get python paramiko [no such file]

paramiko

Solution

I ran across the same issue, but later figured out there was a trailing \n character, which is unseen.

So I'd suggest to call strip() method to remove invisible leading/trailing characters, which could be the offending ones

strip() worked at my side.

Problem

I'm writing a Python script that needs to download a remote xml file to parse it. I'm using paramiko for it. Here is the script: ``` def copyFile(ip, user, pwd, remotePath, localPath): ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) try: ssh.connect(ip,username=user,password=pwd) ### Copy remote file to server sftp = ssh.open_sftp() sftp.get(remotePath,localPath) sftp.close() ssh.close() return ["OK",0,0] except IOError as e: flash(str(e)+" IOERROR") return ["IOERROR: " + str(e),0,0] except Exception as e: flash(str(e)+" OTHER EXCEPTION") return ["Error: " + str(e),0,0] ``` The code returns and IOError saying that the file don't exists. But If I swap the variable for strings, it works perfectly.: ``` `sftp.get("/etc/conf/file-cfg.xml","./conf/file-cfg.xml")` ``` The variables are being passed correctly: ``` `copyFile(ip,username,pwd,"/etc/conf/"+i,"."+i)` ``` I lost a lot of time trying to figure out whats is wrong withou any success. My remote machine : Ubuntu 13.10 x64 Local Machine: Windows 7 x64

Original source