I am trying to make the following script work for the ufw command which is expecting me to press y or n to confirm my command. In addition I want to pass my password to the sudo command (I know, bad idea).
echo 'y' | { echo 'my password'; } | sudo ufw reset
The sudo password bit works but I get the following error message from the ufw reset command:
Resetting all rules to installed defaults. Proceed with operation (y|n)? Aborted
The command is being aborted rather than accepting the 'y' I was trying to send it. Can anyone tell me what I am doing wrong?