hi...

I have written a script for FTP upload using python..

It worked fine when i tried on local boards, but is giving me an error when trying with a remote board via VPN.
this is the error i get:
(104, 'Connection reset by peer')

the machine i developed script on had python2.5 and the one which i am currently running(remote conn) has python 2.4.3

Recommended Answers

All 8 Replies

You should first check the server by using a standard ftp client like filezilla.

You should first check the server by using a standard ftp client like filezilla.

with filezilla, upload worked. Then it must be a bug in my script?:(

with filezilla, upload worked. Then it must be a bug in my script?:(

ftplib.error_perm: 552 File not recognized
i: Bad object type: 1

this is what i got...n i learnt that 552 relates to storage allocation exceeded. but my file is only 6,965 KB

ftplib.error_perm: 552 File not recognized
i: Bad object type: 1

this is what i got...n i learnt that 552 relates to storage allocation exceeded. but my file is only 6,965 KB

It's difficult to help you without the faulty client code.

It's difficult to help you without the faulty client code.

here is my faulty client code...

..................
................
...................

#-- prompt the user for file location


retry=1
while(retry<5):
try:
logging.info("Enter the file location")
file = raw_input()
logging.info(file)
filename= os.path.basename(file)
retry+=1
f=open(filename,"rb")
logging.info("File present")
flag=0
break
except Exception,e:
logging.debug(e)
logging.info("Invalid path, Try again")
flag=1
if flag==1:
logging.info("FILE NOT PRESENT")
exit(1)
else:
pass
#-- upload the file

try:
subprocess.call(,shell=True)
uploadSuccess=1
#logging.info("UPLOAD IN PROGRESS")

except Exception,e:
logging.info(e)
#logging.info("UPLOAD FAILED")
exit(1)


#-- Check whether card has USB interface (i.e., whether it is a 4501 card)
from pysnmp.entity.rfc3413.oneliner import cmdgen
errorIndication,errorStatus,errorIndex,varBinds = cmdgen.CommandGenerator().getCmd( cmdgen.CommunityData('xxx', 'yyy', 1), cmdgen.UdpTransportTarget(('192.168.155.164',161 )),(1,3,6,1,4,1,18489,1,2,1,4,6,3,0))

logging.info("ERROR ON GET:")
logging.info(errorIndication)

logging.info("ERROR STATUS:")
logging.info(errorStatus)
logging.info(varBinds)

value = varBinds[0][1]
#check the first four chars in the tuple
if value[:4]== '4501':
logging.info("USB KEY SUPPORT PRESENT")
USBKey=1
else:
logging.info("USB KEY SUPPORT NOT PRESENT")
exit(1)

#-- query on ccmSDIDUKeyStatus

try:
errorIndication, errorStatus, errorIndex, varBinds1 = cmdgen.CommandGenerator().getCmd( cmdgen.CommunityData('xxx', 'yyy', 1), cmdgen.UdpTransportTarget(('192.168.155.164', 161)), (1,3,6,1,4,1,18489,1,2,4,2,8,0))

logging.info("Error on Get")
logging.info(errorIndication)

logging.info("Error Status")
logging.info(errorStatus)

logging.info(varBinds1)
#-- accessing the object value of varBinds(i.e., USB key status. 1--online, 2--disconnected)
value = varBinds1[0][1]
except Exception,e:
logging.debug(e)


if value == 2:
logging.info("USB KEY STATUS---------- DISCONNECTED")
exit(1)
else:
logging.info("USB KEY STATUS--------------- ONLINE")
USBOnline=1


#--IF USB support present and key online, issue copy software command

if (uploadSuccess=='1' and USBKey=='1' and USBOnline=='1'):
from pysnmp.entity.rfc3413.oneliner import cmdgen
from pysnmp.proto import rfc1902
errorIndication, errorStatus, errorIndex, varBinds = cmdgen.CommandGenerator().setCmd( cmdgen.CommunityData('xxx', 'yyy', 1), cmdgen.UdpTransportTarget(('192.168.155.164', 161)), ((1,3,6,1,4,1,18489,1,2,1,5,7,2,1,0 ), rfc1902.Integer('1')) )


logging.info(errorIndication)
logging.info(errorStatus)
USBUpload=1
else:
logging.info("No support for USB upload")
exit(1)


#--Query USB copy software command status only if a command is issued,else it takes the previous status

if USBUpload==1:
prevStatus=0
while(1):
errorIndication, errorStatus, errorIndex, varBinds = cmdgen.CommandGenerator().getCmd(cmdgen.CommunityData('xxx', 'yyy', 1),cmdgen.UdpTransportTarget(('192.168.155.164', 161)),(1,3,6,1,4,1,18489,1,2,1,5,7,2,2,0))
value = varBinds[0][1]
currStatus=value
if currStatus!=prevStatus:
#if value==1:
#logging.info("'FTP IN PROGRESS")
if value==2:
logging.info("COPY IN PROGRESS")
elif value==3:
logging.info("FAILED TO COPY SOFTWARE FROM USB")
elif value==4:
logging.info("COPIED SUCCESSFULLY")
break
else:
exit(1)

eagerly awaiting any help

I realized it was not a problem with my client code, but a problem with the 'single binary image'(file to be uploaded) I created:P]. Now it's working fine

I realized it was not a problem with my client code, but a problem with the 'single binary image'(file to be uploaded) I created:P]. Now it's working fine

There are many possible improvements in your code. Write functions and classes !

There are many possible improvements in your code. Write functions and classes !

@Grib: thanks a lot...I'll consider it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.