Quicky testing TFTP Client (and server) with tftpy

To run a server (easy_install tftpy first):
from tftpy.TftpServer import TftpServer
TftpServer( 'tftp' ).listen( 'localhost', 8069 )

Which serves up the files in the 'tftp' directory on port 8069 (69 is the standard tftp port).  To download an existing file from the server:

from tftpy.TftpClient import TftpClient
TftpClient( 'localhost',8069).download( 'exists', 'downloaded.txt' )
which should download the file "exists" from the server to the file 'downloaded.txt' (as long as the file exists).


  1. zoobab

    zoobab on 04/05/2010 9:22 a.m. #

    I got the following error, did I miss something?:

    >>> from tftpy.TftpServer import TftpServer
    >>> TftpServer( 'tftp' ).listen( 'localhost', 69 )
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/usr/lib/pymodules/python2.6/tftpy/TftpServer.py", line 36, in __init__
    raise TftpException, "The tftproot does not exist."
    tftpy.TftpShared.TftpException: The tftproot does not exist.

  2. Mike Fletcher

    Mike Fletcher on 04/05/2010 10:01 a.m. #

    We've told it to serve files from a directory called 'tftp' there. That directory must exist for the call to work.

    Similarly, you've told it to listen on port 69, which is a privileged port (admin-only), using port 8069 would likely work better for a non-admin user.

Comments are closed.


Pingbacks are closed.