Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm not sure if this is even possible but can I show the stdout of a linux command via webserver?

The command I want to run is echo 'status' | nc localhost 4730 which returns a string with status of the gearman job server.

$echo 'status' | nc localhost 4730
function1      0       0       0
function2      0       0       1

My server's running nginx. I want to open a URL like http://domain.tld/gearman-status and it should return the current status by running that command.

What should I put in the location block of nginx to do that?

location /gearman-status {


share|improve this question
up vote 4 down vote accepted

nginx lacks CGI support so it can't execute any scripts directly. You'll need to setup FastCGI server and call it from nginx by using fastcgi_pass in your location directive. There is example of such FastCGI wrapper in nginx wiki - see this link.

share|improve this answer
Thanks Alex. FastCGI does seem like an overkill for this simple requirement but as the perl script is given on the wiki for this case, I'd go with it. – Mridul Kashatria Jul 3 '11 at 15:34

You can just write a small PHP or perl file and put it in the required path. This small file will execute the script or commands you want and print the output. You can use the backquotes `command` to do this.

share|improve this answer

Your Answer


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.