Run cgi-script on commandline as user www?

Solution 1:

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.

Solution 2:

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