I would like to used the yes
command so that GNU parted does not wait for user input :
root@195-xxx-xxx-xxx:/proc# parted /dev/sda unit B resizepart 2 1166016512B
Warning: Shrinking a partition can cause data loss, are you sure you want
to continue?
Yes/No? y
Information: You may need to update /etc/fstab.
root@195-xxx-xxx-xxx:/proc# echo $?
0
However using yes
does not work here :
root@195-xxx-xxx-xxx:/proc# yes | parted /dev/sda unit B resizepart 2 166016512B
Warning: Shrinking a partition can cause data loss, are you sure you
want to continue?
root@195-xxx-xxx-xxx:/proc# echo $?
1
Edit:
The --script
option does not work as well :
root@195-xxx-xxx-xxx:/proc# parted --script /dev/sda unit B resizepart 2 1166016512B
Warning: Shrinking a partition can cause data loss, are you sure you
want to continue?
root@195-xxx-xxx-xxx:/proc# echo $?
1
yes
after the size. Like @nictrix, this did not work for me. I proposed an edit to put it after the partition number, which did. – Reid Nov 27 '18 at 00:09