• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

PHP help

PowerMacG5

Diamond Member
I want to call a program from my Linux computer using php. I created this file test.php:
<? system("snortsnarf"); ?>
and it works as expected from the command line typing "php test.php". Now, the problem comes in when I try to run it from a web browser. The page loads without any errors, but the script snortsnarf does not execute as expected. The file snortsnarf is a shell script I created to execute Silicon Defense Snortsnarf program with the options I want. This file is located in /usr/sbin/ with the permissions set to 755. I have tried replacing the system call with exec, and same thing happens. I have also tried putting within the quotes the actual call to the snortsnarf.pl file from Silicon Defense with the options. Does anyone know what I can do to fix this? I have tried using "ping 192.168.1.1 -c 5" to test the system call, and that works. Can anyone help me?
 
Originally posted by: BingBongWongFooey
Perhaps your configuration in php.ini prevents executing shell statements? does system("echo hello"); work?

<? system("echo hello"); ?>
Works fine both from command line and web browser. Like I said in the case of the shell script I created, from the Command Line, if I type php test.php it works, but from a web browser it doesn't work. One of my friends whom I contacted said that it may not work because of the mod_php with apache uses it's own interpreter and not the default cgi php interpreter. I don't know, but thanks for the help so far, anymore is appreciated.
 
Normal users don't normally have /usr/sbin in their path. Try moving your script (or a copy of it) to /usr/bin, or some other place that normal users can access.
 
Still doesn't work. I copied "snortnsarf" to /usr/bin/ then changed the code in test.php to read:
<? system("/usr/bin/snortsnarf"); ?>
and it still doesn't work.
 
Back
Top