I work with a couple of arduino yuns and want to write a script to upload sketches on multiple of them. Let's assume I have a compiled arduino program:sketch.hex. Now I'd like to upload this file via LAN. For a single device it works like this.
Copying the sketch onto the device. (password required) scp sketch.hex email@example.com:/tmp/sketch.hex
Opening an ssh session with the device. (password required) ssh firstname.lastname@example.org
And then load the program onto the Atmega with the following 2 commands. merge-sketch-with-bootloader.lua /tmp/sketch.hex run-avrdude /tmp/sketch.hex
Now my question would be, how to do this for multiple arduinos (yun1,yun2,...,yunN) without entering actually ssh-ing into each single device in order to run the bottom 2 commands.
Hope the question is not too confusing and thanks a lot in advance.
If you don’t want to use SSH and the command line, the simplest way is to go the Yun’s configuration web pages. Log in, and the first page shows the current network status, and has a section with a button that allows you to upload the sketch .hex file.
If you don’t want to do even that much, and you want to remotely load files directly from another computer automatically (without manually typing any commands) then you will likely have to do some one-time setup work on the Yun. I’m sure there are many ways to do it, but basically you need a way to send a file, and then run a shell script. My first thought would be to write a CGI script (Python, PHP, or something like that) which accepts a file upload web request, saves the file, and then programs the sketch using the commands you list.
A search on this forum about how to set up a PHP or Python CGI script on the Yun should turn up some examples. A general Google search on CGI scripting should give you some ideas of how to handle a file upload and run a shell script.
With that working, then you would need to write some code on your host computer to give it a list of Yun addresses, and make the web request to each Yun, sending the file.
Please do post the results of your research and experimentation - I’m sure others will like to hear about it.