I've googled this, and almost all I could find is to answer a bash script and this doesn't work for me. The answers I found told to do:
echo "yes" | ./script
or
./script <<< yes
or something like that. It didn't work for me. My guess is that's because what I want to do is to auto answer an executable program, not a script. More specifically, I want to auto answer parted. Here
parted -a optimal /dev/sda mklabel msdos
Warning: The existing disk label on /dev/sda will be destroyed and
all data on this disk will be lost. Do you want to continue?
Yes/No? _
I try to do
echo "yes" | parted -a optimal /dev/sda mklabel msdos
and
parted -a optimal /dev/sda mklabel msdos <<< yes
Both methods didn't work. Those didn't answer yes to parted prompt.
So, how can I automatically answer that parted prompt without using a bash script?