0

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

adrTuIPKJ44
  • 2,793
  • 2
  • 9
  • 8
  • Have you tried `tftp Server_IP Port GET filename.txt` ? It would work with [this windows client](http://www.tftp-server.com/tftp-client.html), no idea about yours. – Aaron Oct 20 '16 at 14:40
  • 1
    `get filename.txt` is *not* a `bash` command; it is a command sent to the FTP server by `tftp`. – chepner Oct 20 '16 at 14:42
  • @Aaron No it does not work, the server is Linux – adrTuIPKJ44 Oct 20 '16 at 14:54
  • Looks like the client's syntax for passing a command is `tftp Server_IP Port -c GET filename.txt`. I think this should fix your problem, I'll post it as a solution. – Aaron Oct 20 '16 at 14:55
  • @Aaron I just tried, it does not work – adrTuIPKJ44 Oct 20 '16 at 15:00
  • Hmm, can you report anything about your `tftp` client version? I was using [this manpage](https://linux.die.net/man/1/tftp), according to which the `-c` syntax should work. – Aaron Oct 20 '16 at 15:03
  • @Aaron I'm trying to, but it doesn't give much interesting stuffs – adrTuIPKJ44 Oct 20 '16 at 15:07
  • @Aaron Isn't there another way by backgrounding the bash session ? – adrTuIPKJ44 Oct 20 '16 at 15:09
  • You may bet able to pass commands to the `tftp` process through its standard input ; have you tried the pipe solution I commented on my answer? – Aaron Oct 20 '16 at 15:10

1 Answers1

2

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.

Aaron
  • 24,009
  • 2
  • 33
  • 57