I'm working on migrating my development environment from Windows to OS X and have run across a problem with TFTP. I use TFTP to upload files to an embedded network device, this is the only option to get the files on the device (no SCP support is provided).
Every time I build firmware for this device, there's a series of three files that need to be uploaded to it. On Windows I had some simple scripts that would upload all of the files I needed in one shot which makes deploying everything much simpler. These scripts were easy because the Windows TFTP client is run in one-line commands like this:
tftp -i <Server IP Address> PUT <Local Filename> <Server Filename>
It doesn't seem that there's any way to upload a file with one command like this on OS X. Instead, you have to open the tftp program and execute a series of commands that looks something like this:
$ tftp
tftp> connect <Server IP Address>
tftp> mode binary
tftp> put <Local Filename> <Server Filename>
tftp> quit
So far I have not had any luck in figuring out how to write a script to do this, although I don't have a ton of experience with Unix shell scripting. Has anyone tried to do anything similar and come up with any solutions?
Best Answer
You should be able to use a "here document" to feed commands to the
tftp
program in a script: