To start with, please use [code][/code]
tags around your code and data, to preserve formatting and to improve readability. Please do not use quote tags, colors, or other fancy formatting.
is used for interpreting scripts in restricted, posix-compliant lowest-common-denominator mode, and many shell-specific features may be unrecognized or have their behavior altered. This is mostly recommended for system startup scripts and other cases where portability and standardization are important. When this isn't required, you should use #!/bin/bash
(or the path to another shell that has more modern, advanced features available, such as ksh or zsh).
I'm not sure if all the features in your script (specifically brace expansion) are supported by posix, so be sure to specify bash instead.
This is just a standard for loop
, using brace expansion
to generate the input word list. Each digit from 0 to 3 will be read into the variable "i" in turn, then the sub-commands run. Assuming there are 4 drives connected, with those numbers in their device names, they should all be processed.
cdrecord -eject dev=/dev/sr$i $1 &
For each loop iteration, run the supplied cdrecord
command, with the current value of the variable "$i
" inserted at that point. The first command parameter of the script (the path to the iso), "$1
" is also inserted. Finally, the "&
" at the end forks the command into the background, so that the loop can continue immediately, instead of waiting for it to finish first.
Note that this part of the script is not very safe. There's no test to ensure that the $1
input is a valid file first, and since the variables are unquoted, any spaces in the filename would be word-split before run, breaking the command.
It's vital in scripting to understand how the shell handles arguments and whitespace. Read these links:
keyword just completes the loop, of course.
Other than that, so as long as the cdrecord command works when run on its own, the script should work as well. Read the whole bash guide I linked to above for more on the basics of scripting.
BTW, there used to be a small program available in the debian repositories that would write an image to multiple drives at once, but I can't seem to find it now. It was also named something like multiburn