Search code examples
bashtftp

How to make those 2 commands work together in one bash line?


I would like to connect via tftp with: tftp Server_IP Port

THEN to get a file from the server with: get filename.txt

The server I'm trying to connect to in FreeBSD, here is doc about the FreeBSD tftp client here

I want to make those two commands in one Bash line, I was thinking of tftp Server_IP Port; get filename.txt but it does not work.

Any suggestion ?

Thanks


Solution

  • Depending on its implementation, your tftp client might have an option to accept a command as a parameter instead of opening an interactive session.

    If it isn't the case, it should at least accept input from its standard input (stdin). You can send data through this stream by piping a previous command, for example a simple echo :

    echo "GET filename.txt" | tftp Server_IP Port
    

    The tftp client might detect it receives data from a pipe and avoid launching an interactive tftp shell ; if it's not the case, just add ;quit at the end of your command in order to exit the FTP session and thus the tftp process.