4

Please help me to upload a file to a TFTP server using python. I'm using tftpy module. In the document(http://tftpy.sourceforge.net/sphinx/index.html) it says

class tftpy.TftpClient.TftpClient(host, port, options={})
    upload(filename, input, packethook=None, timeout=5)

what should be the filename- is it a path of the remote server where the file already existing or is it just new file name which server will create using the filename in the default directory or path for the new file (filename) to create ?

Do I have to have to create a file of same name as input file in the server before upload?

What is the default directory the server will upload files to?

If so, what is the other way for the server to create a file using the name passed (filename)?

What I'm sending is

tftp_obj.upload('something.txt','/home/username/project/example.txt')

I'm sending the new file name something.txt which doesn't exist in the server I'm getting the error message:

raise TftpException, "Received ERR from server: " + str(pkt)
tftpy.TftpShared.TftpException: Received ERR from server: ERR packet: errorcode = 1
msg = File not found

I get the same error if I create the file (same as input file name) in the remote server under root (/example.txt) (assuming the default folder it uploads to is root) and give path for filename parameter

tftp_obj.upload('/example.txt','/home/username/project/example.txt')

Same error when I pass just the existing file name

tftp_obj.upload('example.txt','/home/username/project/example.txt')

Please help with examples.

sans0909
  • 395
  • 7
  • 20

1 Answers1

0

From the TftpClient Documentation it sounds filename is the name that will be given to the uploaded file on the remote TFTP server, and input is the data source of the local file you are uploading

upload(filename, input, packethook=None, timeout=5)

This method initiates a tftp upload to the configured remote host, uploading the filename passed. It reads the file from input, which can be a file-like object or a path to a local file...

Community
  • 1
  • 1
Andrew Mo
  • 1,433
  • 9
  • 12
  • I know that, but does it creates the file with the filename in the server and if so in which path does it creates and why am I getting file not found error? – sans0909 Oct 19 '17 at 10:40