stderr
stderr

Reputation: 141

Perl script: different results form command line and CGI

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?

Upvotes: 1

Views: 198

Answers (1)

Alex Reynolds
Alex Reynolds

Reputation: 96974

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.

Upvotes: 1

Related Questions