Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm running FreeBSD 7 and apache-2.2.13.

I am trying to debug a cgi script at http://www.example.org/cgi-bin/printenv . This script is a simple script written in Bourne shell.

I would like to run this script from the unix commandline, as user 'www'. However, the user 'www' does not have a shell (by design). This means I cannot 'su' to user 'www' to execute this script:

# su www -c /usr/local/www/apache22/cgi-bin/printenv
This account is currently not available.

# su - www -c /usr/local/www/apache22/cgi-bin/printenv
su: no directory

How can I run this script as user 'www'?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Your first example is fine - that error probably means the shell is currently pointed to nologin. Simply change it to a valid shell or use something like sudo which is sort of a hack but would work.

[root@monkey]# grep monkey /etc/passwd
monkeyman:x:100:101:monkeyman:/home/monkeyman:/sbin/nologin

[root@monkey]# sudo -u monkeyman echo "hi"
hi
[root@monkey]# su monkeyman -c 'echo hi'
This account is currently not available.
share|improve this answer
    
This is Linux however I suspect the same behavior. –  WinkyWolly Mar 23 '11 at 0:59
1  
The same behavior happens on Linux. However, Linux has a su --shell=/bin/sh option to bypass this problem. –  Stefan Lasiewski Mar 24 '11 at 17:39
    
I was hoping to avoid sudo (I was hoping to avoid any system modifications). But it seems this is the only option for me. Thanks. –  Stefan Lasiewski Mar 24 '11 at 17:40
    
Ah, I never thought to check if I could set a shell with su. Good catch :). –  WinkyWolly Mar 26 '11 at 18:49

Have you tried what is suggested on Run as different user under FreeBSD?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.