A SSH error during put operation

Oltmans rolf.oltmans at gmail.com
Tue Jan 20 09:08:11 EST 2009


Hey all,

I've been using Paramiko for sometime now and I never had any
problems. I've already submitted this question to Paramiko mailling
list but I thought I should post it in CLP as someone might have used
it in past. I'm using Paramiko for SSH. Are there any other good SSH
libraries that you've found useful--please let me know?
There is this script that used to work absolutely fine. But for some
reason it's broken now. First, here is the script. Error is pasted at
the end. Please help as I've searched the Internet, archives but
couldn't find anything and it's been quite a few hours now. I will
really appreciate any help. Thanks in advance.

Script:
from __future__ import with_statement
import paramiko
import base64,os, sys
from paramiko import AutoAddPolicy, SSHClient
from decimal import *
class CustomException(Exception):
     def __init__(self, value):
          self.parameter = value
     def __str__(self):
          return repr(self.parameter)

def ConnectCopy(domainInfo, uname, pwd,
portNumber,zipName,completePath):

    #domainInfo is a list, where domainInfo[0] = host name and
    #domainInfo[1] is the remote path.
    #----
    #zipName is the name of zip file. It will be appended with
domainInfo[1] so
    #it will look like c:\Test\ABC.zip
    #----
    #completePath is the local file path , that we intend to copy to
remote host

    domainName=""
    domainName=domainInfo[0].strip()
    client= paramiko.SSHClient()

    client.set_missing_host_key_policy(AutoAddPolicy())
    print 'Complete Path= '+completePath

    try:
        client.connect
(domainName,portNumber,username=uname,password=pwd)
    except CustomException, (e):
        print "Error="+e.parameter


    print "Domain Info= "+domainInfo[1]

    try:
        sftp=client.open_sftp()
        sftp.put(os.path.normpath(completePath),os.path.normpath
(domainInfo[1])+"\\"+zipName)
        sys.stdout.write('\n')
        print 'File has been copied'
    except CustomException,(e):
        print "Error = "+e.parameter
        sys.exit()




    sftp.close()
    client.close()




if __name__=="__main__":
    ConnectCopy(['example.example.com','C:\\test'],'username','pwd',
8922,'ABC.zip','C:\\ABC.zip')





and here is the Error:

Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.



C:\Release>connectdeploy1.py


Traceback (most recent call last):
  File "C:\Release\ConnectDeploy1.py", line 56, in <module>
ConnectCopy(['example.example.com','C:\\test'],'username','pwd',
8922,'ABC.zip','C:\\ABC.zip')
  File "C:\Release\ConnectDeploy1.py", line 39, in ConnectCopy
    sftp.put(os.path.normpath(completePath),os.path.normpath(domainInfo
[1]))
  File "C:\Python25\lib\site-packages\paramiko\sftp_client.py", line
539, in put

    fr = self.file(remotepath, 'wb')
  File "C:\Python25\lib\site-packages\paramiko\sftp_client.py", line
238, in ope
n
    t, msg = self._request(CMD_OPEN, filename, imode, attrblock)
  File "C:\Python25\lib\site-packages\paramiko\sftp_client.py", line
589, in _re
quest
    return self._read_response(num)
  File "C:\Python25\lib\site-packages\paramiko\sftp_client.py", line
637, in _re
ad_response
    self._convert_status(msg)
  File "C:\Python25\lib\site-packages\paramiko\sftp_client.py", line
667, in _co
nvert_status
    raise IOError(text)
IOError: SfsStatusCode.Failure




More information about the Python-list mailing list