How to automatically answer interactive cli program (not script) with bash script?

Solution 1:

With parted, you can just add the -s option:

parted -a optimal -s /dev/sda mklabel msdos

From the Trusty man page for parted:

[...]
       -s, --script
              never prompts for user intervention
[...]