You don't need any expect scripts. There are CLI tools perfectly usable from plain shell or Perl/Python scripts, that don't need any terminal interaction.
For partitioning, you can use sfdisk
, for making file systems, you can use the appropriate mkfs.xxx
. You can get the current partitioning scheme from sfdisk -d
in a wonderful, easy-to-parse format, you can decide whether you want a different partitioning or not, then use sfdisk
again to load the new partitioning scheme. mkfs.xxx
binaries are also ready to be used from scripts, when used with the proper command-line options.
To handle multiple disks in parallel, I suggest to implement a script for a single disk, and run as many scripts in parallel as needed.