1

On RED HAT LINUX: Running APACHE

From a PHP script I want to run a Perl script and am trying to do so with the following command:

exec("/usr/bin/perl /home/path/to/perlscript/main.pl", $output, $result); 

This seems to fail because the PERL script needs to be run by another user (USER1).

I have tried without success to use SUDO. I have to run the script as (USER1) instead of user (APACHE) because (USER1) has more privileges than APACHE user.

Any idea how I would do this?

8
  • 4
    I would hope that you weren't able to get the web server to sudo anything! You'll need to alter the permission of the file so that the web server can access and run it. Commented Jan 24, 2012 at 21:22
  • USER1 (or ROOT) has to be the one run the Perl Script since that user has privileges to run certain commands like Kill process. Does that make sense? Commented Jan 24, 2012 at 21:28
  • 3
    Yes, it's comprehensible as a sentence, but no, it's a terrible, terrible idea. If you let your web server run things as root, you're begging for trouble. The web server, as a user, can kill off processes that it creates. Commented Jan 24, 2012 at 21:30
  • 2
    point taken. back to the drawing board. Commented Jan 24, 2012 at 21:40
  • What does the Perl script do? Commented Jan 24, 2012 at 21:42

1 Answer 1

0

Without fully knowing what your perl script is doing, maybe consider running a cronjob that runs the perl script. This way it's isolated from Apache altogether and still can operate as root without compromising your server.

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

1 Comment

Or write a daemon that monitors your database server by what ever means it allows for pinging it or monitoring it through SNMP.

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.