sudo: no tty present and no askpass program specified (trying to start apachectl)

we are running hudson to monitor a couple of shell jobs. The problem is that hudson runs all jobs as user "hudson".

That's ok, except for some special commands that require super user rights, like "chown" and "apachectl" We have the following inour sudoers file: (visudo)

Defaults:hudson !requiretty
%hudson ALL = NOPASSWD: /usr/sbin/apachectl, /bin/chown

But this gives us the following error when we want to call apachectl -k graceful in our shell script:

sudo: no tty present and no askpass program specified

Does anyone have any idea on how we can solve this?


[Moved from the comment above]

Your script may be finding the apachectl binary somewhere else in $PATH other than /usr/sbin/apachectl. This would fail to match your existing sudoers entry. If you call the command with an explicit path (i.e., use /usr/sbin/apachectl in your script, rather than just apachectl) you can make sure you're using the right one. This is a good practice in general.