我安装并编写了以下无法放入文件的Paramiko.它很容易'获取'文件并在其上执行'ls'命令.
#set username & password username='runaway' password='runaway' port=22 source= '/Unzip.sh' destination ='/var/mpx/www/http' #SFTP client.load_system_host_keys() print " hostname =%s \n username=%s \n password=%s \n" (hostname,username,password) t = paramiko.Transport((hostname, port)) t.connect(username=username,password=password) sftp = paramiko.SFTPClient.from_transport(t) sftp.put(source,destination) #sftp.close() #t.close()
使用'put'命令会出现以下错误和堆栈跟踪 -
File "upload_file.py", line 84, in ? sftp.put(source,destination) File "/usr/lib/python2.4/site-packages/paramiko/sftp_client.py", line 522, in put fr = self.file(remotepath, 'wb') File "/usr/lib/python2.4/site-packages/paramiko/sftp_client.py", line 221, in open t, msg = self._request(CMD_OPEN, filename, imode, attrblock) File "/usr/lib/python2.4/site-packages/paramiko/sftp_client.py", line 572, in _request return self._read_response(num) File "/usr/lib/python2.4/site-packages/paramiko/sftp_client.py", line 619, in _read_response self._convert_status(msg) File "/usr/lib/python2.4/site-packages/paramiko/sftp_client.py", line 649, in _convert_status raise IOError(text) IOError: Failure
我该如何克服这个问题?
解决方案对我来说似乎很有趣!
source= '/Unzip.sh' destination ='/var/mpx/www/http/Unzip.sh'
刚刚修改了目标路径以包含文件名.没想到像Python这样的一些错误.