views:

75

answers:

4
+2  Q: 

PHP system() help

Hello,

I have this shell script

    #!/bin/sh

#############################################################
# Example startup script for the SecureTrading Xpay4 client #
# Install Xpay4 into /usr/local/xpay4                       #
# To run this script automatically at startup, place the    #
# following line at the end of the bootup script.           #
# eg. for RedHat linux: /etc/rc.d/rc.local                  #
#                                                           #
# /usr/local/xpay4/xpay4.sh                                 #
#############################################################

# Configuration options

# Path to java executable
JAVAPATH=/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home

########## Do not alter anything below this line ##########
echo "Starting Xpay4. Please ensure the Xpay4 client is not already running"
$JAVAPATH/java -jar /usr/local/xpay4/Xpay4.jar /usr/local/xpay4/xpay4.ini &

And I am trying to run it using,

system("/x/sh/shell.sh");

I am doing this when a user navigates to a certain page on my site, however I am getting just a white blank screen is there a way to error check with system(), I am currently using

error_reporting(E_ALL | E_STRCIT)

and that is applied site wide

A: 

Is there a safe-mode enabled? As a manual says:

When safe mode is enabled, you can only execute files within the safe_mode_exec_dir. For practical reasons, it is currently not allowed to have .. components in the path to the executable.

You can check safe_mode with this script:

<?php
    $safe = ini_get("safe_mode");
    var_dump($safe);
?>
Tomasz Tybulewicz
A: 

You might also try displaying the output from your script in case there is some issue with calling it from php:

system("/x/sh/shell.sh", $output); echo $output;

Hopefully that will give you a more interesting output.

Keare
ended up being the file path was incorrect
sea_1987
A: 

may be

chmod +x /x/sh/shell.sh

and try

var_dump(system("/x/sh/shell.sh"));

system() returns false on error

Maksim Burnin
A: 

I've found that when I get a blank page it's typically a syntax error. Run your php script from the command line with -l (lower-case L) option, like php -l myscript.php. That will check the code for any syntax errors. Then you can continue troubleshooting from there if necessary.

Timothy