Error in script confirmed and to be continued

Hello.

I have a problem.

When i run 1.sh, ask me yes or no, and, if i asnwerd yes, there continue the procediment

"sudo -u root echo hello"

. All without putting it into a single script, and who uses the confirm many more scripts.

I have two script.

1 with the following code confirm.sh
#################################

#!/bin/bash
while true; do
    echo
    read -p "esta seguro de hacer lo que sea que vaya a hacer (yes/n)" yn
    case $yn in
        yes ) break;;
        not ) exit;;
        * ) echo "por favor responda yes o no";;
    esac
done

2� script 1.sh
#######

confirm.sh normal ("sudo-u root stopserver.sh")

I did not understand.

You want a script that takes [yes|no] and if the answer is "yes", you want it to echo some text, right?
As a side note, you do not need to sudo for a simple echo. Every user with a shell can do this.

1 Like

Thanks.. i change de code, but this is the problem