sudo command and how to auto get password

Posted by user108988 on Ask Ubuntu See other posts from Ask Ubuntu or by user108988
Published on 2012-12-13T15:36:51Z Indexed on 2012/12/13 17:16 UTC
Read the original article Hit count: 200

Filed under:

I got a problem that:

I have a file .sh

    #!/bin/bash 

var=$(zenity --forms --title="T?t gi? v? yêu nhé" \
    --text="V? mu?n t?t máy sau bao nhiêu phút n?a" \
    --separator="," \
    --add-entry="V? di?n s? vào dây")
case $? in
    0)  sudo shutdown -h $var           
    ;;
    1)
        exit 0;;
    -1)
        echo "An unexpected error has occurred."
    ;;
esac

How can sudo command autofill the password from echo command or a file. I read about sudo -S options, but i dont know how it works. Anyone can give an example about it! Thanks guys

© Ask Ubuntu or respective owner

Related posts about sudo