6

I need to download the complete directory structure from a TFTP server. Is there some simple way to do that? If that is not possible, than how could I download all files individually (provided I have a list of all files on the server)?

7

You cannot list files or directories with TFTP. Read first paragraph of RFC 1350 - 1. Purpose. (or better yet, read the whole document.)

If you have a file list in say files.txt you can use expect, curl or other to automate a download. Simple example (as a starter) using curl:

tftpbatch:

#!/bin/bash

server="tftp://$2"

while IFS= read -r path; do
    [[ "$path" =~ ^\ *$ ]] && continue
    dir="$(dirname "$path")"
    printf "GET %s => %s\n" "$path" "$dir"
    ! [ -d "$dir" ] && mkdir -p "$dir"
    curl -o "$path" "$server/$path"
done < "$1"

Run with:

./tftpbatch files.txt "10.0.0.5:69"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.