문제

Linux Ubuntu 12.04의 Eclipse에서 Test를 자동화하려고 시도하고 FTP 서버를 다음을 테스트해야합니다. 호스트에서 파일을 만들고 FTP 당 다른 PC로 전송 한 다음 다른 이름으로 내 호스트로 다시 전송해야합니다.그런 다음 비교 해야하는 두 개의 파일이 있습니다.나는 이렇게 시작했다 :

    #create the two files
    firstFilename = "first_testfile.txt"
    secondFilename = "second_testfile.txt"
    os.system("echo \"test\" > {0}".format(firstFilename))
    os.system("touch {0}".format(secondFilename))

    #setup FTP connection transfer file to other computer
    ftp = self.setupFTP()
    ftp.set_pasv(True)
    f = open(firstFilename)
    ftp.storbinary("STOR {0} ".format(firstFilename), f)
    f.close
    ftp.quit()
    #setup FTP connection transfer file back to host (other filename)
    ftp = self.setupFTP()
    ftp.set_pasv(True)
    f = open(secondFilename, "wb")
    ftp.retrbinary("RETR {0} ".format(secondFilename), f.write)
    ftp.quit()
    #comparison-part will be implemented later
    firstOutput = os.system("cat {0}".format(firstFilename))
    secondOutput = os.system("cat {0}".format(secondFilename))
    #compare somehow
.

이 코드를 실행하면 다음 오류가 발생합니다.

ftp.retrbinary("RETR {0} ".format(secondFilename), f.write)
error_perm: 550 second_testfile.txt : No such file or directory
.

누구든지 내가 뭘 잘못했는지 알고 있니?

도움이 되었습니까?

해결책

편집 & 해결 : 내 문제를 발견했습니다.

여야합니다.
ftp.retrbinary("RETR {0} ".format(firstFilename), f.write)
.

대신

ftp.retrbinary("RETR {0} ".format(secondFilename), f.write)
.

Rether 이후 FTP의 파일이 호출되는 방법 대신 파일을 파일을 호출하는 대신 파일을 호출하는 방법을 알려야합니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top