What good is a partition of size zero?
Expect runs in tcl, as I recall, so there may be looping constructs in tcl you can include. The man page does not show and flow of control commands:
Man Page for expect (all Section 0) - The UNIX and Linux Forums You could generate the expect script using a shell loop. You can generate it on the fly as a named pipe or with commands from stdin in interactive mode:
The
-f flag prefaces a file from which to read commands from. The flag
itself is optional as it is only useful when using the #! notation (see
above), so that other arguments may be supplied on the command line.
(When using Expectk, this option is specified as -file.)
By default, the command file is read into memory and executed in its
entirety. It is occasionally desirable to read files one line at a
time. For example, stdin is read this way. In order to force arbi-
trary files to be handled this way, use the
-b flag. (When using
Expectk, this option is specified as -buffer.)Notethatstdio-buffering-
maystilltakeplacehoweverthisshouldn'tcauseproblemswhenreadingfromafi-
foorstdin.
If the string "-" is supplied as a filename, standard input is read
instead. (Use "./-" to read from a file actually named "-".)
The
-i flag causes Expect to interactively prompt for commands instead
of reading them from a file. Prompting is terminated via the exit com-
mand or upon EOF. See interpreter (below) for more information.
-i is
assumed if neither a command file nor
-c is used. (When using Expectk,
this option is specified as -interactive.)
-- may be used to delimit the end of the options. This is useful if
you want to pass an option-like argument to your script without it
being interpreted by Expect. This can usefully be placed in the #!
line to prevent any flag-like interpretation by Expect. For example,
the following will leave the original arguments (including the script
name) in the variable argv.
#!/usr/local/bin/expect
--
Note that the usual
getopt(3) and
execve(2) conventions must be
observed when adding arguments to the #! line.