5

I want to execute the tftp command without entering into the "tftp command line".

I have tried the below commands:

tftp xx.xx.xx.xx -c put file1 file2
tftp xx.xx.xx.xx -m binary -c file1 file2

But I got:

usage:tftp host-name [port]
tftp>

After the "usage:" message its entering the tftp command line.

I have tried it with the verbose option turned on.

I just want to know if the command I given worked properly. The "usage:" message makes it seem like it's not the correct usage of the tftp command.

This command is to be invoked from a Bash file which will be invoked from a CLI application I am working on.

I have followed the advices on this link : https://superuser.com/questions/581812/put-file-with-tftp-client-in-linux

runner
  • 165

2 Answers2

5

You can use heredoc (<<) to enter the commands to execute one after another:

tftp host <<'EOF'
Enter
Commands
Here
EOF

Example:

$ tftp localhost <<'EOF'
> ascii
> status
> quit
> EOF

tftp> tftp> Connected to localhost.
Mode: netascii Verbose: off Tracing: off
Rexmt-interval: 5 seconds, Max-timeout: 25 seconds
tftp> 

$ 

If you desired tftp command is

get file1 /home/foobar/test.txt

you can do:

$ tftp host <<'EOF'
> get file1 /home/foobar/test.txt
> quit
> EOF
heemayl
  • 93,925
0

Install the tftp-hpa package - its name is "HPAs tftp-client".
It has the interface you are looking for and is available via the universe repository on Ubuntu 24.04.

You can install it with

sudo apt install tftp-hpa