1

Warning: I'm perl and CGI beginner so this can be stupid question.

I write a really simple perl script which should get info about open files and running processes on system. There is something like this function for processes:

sub num_processes() {
    my @lines = `/bin/ps -ef`;
    return scalar @lines;
}

If I run it from bash, it returns all running processes on system but when I run it via apache and CGI it retruns only 2 processes (running script and running 'ps -ef'). This CGI script runs under user with shell (/bin/bash) enabled. Is there any posibility how to get all the processes via apache and CGI?

1
  • so num_processes returns size of @lines array? Commented Jul 27, 2013 at 19:46

1 Answer 1

1

Your CGI script will run as the Apache user account. Your shell call will run as your user account. This is probably why you get two different answers. Take a look at something like suEXEC to manage the user under which CGI scripts are run.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for reaction but I forgot to add info, that the user who runs scipt is different from apache one (thanks to suexec) and has a shell enabled.
Two different users will see different process lists, so you are probably running into expected behavior.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.