I want to restart apache from a bash in linux (OpenSUSE).
I am trying to read the root password from a file (stdin). This is how I do it:
exec < /opt/otrsadm/stdin
read a1
sudo apache2ctl -k graceful
echo $a1
I get this in my log:
[Mon Sep 12 23:23:12 2011] [error] [client 192.168.1.101] Restarting apache
[Mon Sep 12 23:23:13 2011] [error] [client 192.168.1.101] sudo
[Mon Sep 12 23:23:13 2011] [error] [client 192.168.1.101] :
[Mon Sep 12 23:23:13 2011] [error] [client 192.168.1.101] no tty present and no askpass program specified
What's my problem and how do I fix it?
The sudo -S option reads the password from stdin.
The -S (stdin) option causes sudo to read the password from the standard input instead of the terminal device.
echo "password" | sudo -S apache2ctl -l graceful
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.