468,765 Members | 1,745 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,765 developers. It's quick & easy.

exec stopped working?

I wonder if anyone has experienced something like this, as it seems
truly bizarre and is causing me to tear out my hair (what little there
is left of it)....

The exec() function just suddenly stopped working, for no discernable
reason. Here is the code:

$execdir = $homedirectory."/".$genename."/".$rundir;

// Run the Python script on the Exported text file(s).
$cmd = "/home/ehringer/MAELab/bin/Parse_AD_Output.py --FinalCall ".
$execdir;

$debug = 0;
if ($debug) {
echo "<brcmd = ".$cmd."<br>";
}

echo "<h3>Difference Report for Project: ".
$projectname."&nbsp;&nbsp;&nbsp;&nbsp;Gene: ".
$genename."&nbsp;&nbsp;&nbsp;&nbsp;SNP: ".$snpname."</h3>";
// echo the selected filenames here as a record:
echo "<h4>Files compared in this run:<br>";
foreach ($filename_arr as $file) {
echo $file."<br>";
}
echo "</h4>";
echo "<button onclick=\"location.href='saveTempDiff.php?cmd=".
$cmd."'\" >Save As Temp Comparison File</button>&nbsp;";
echo "<button onclick=\"location.href='saveFinalDiff.php?cmd=".
$cmd."&gene=".$genename."&snp=".$snpname."'\" >Make Final Calls</
button>&nbsp;";
echo "<input type='button' onClick='location.href=\"selectProject.php
\"' value='Select Projects' class='btn'>&nbsp;";
echo "<button onClick='location.href=\"logout.php\"'><button>Log out</
button><br>";
echo "<pre>";
// Now execute the PHP function that runs an external program and
capture the output
// in an array.
exec($cmd,$output,$rtnvar);
if ($rtnvar) {
foreach ($output as $var) {
if ( (strcmp("seen before!!",$var)==0) || (strpos($var,"CALLS")>0))
{
continue;
}
echo $var."<br>";
}
} else {
echo "<h3>Execution of Parse_AD_Output failed!</h3><br>";
}
echo "</pre>";
?>
If I set debug true, and output the cmd variable, I can cut-&-paste
the cmd, and it executes fine at the command line in the target
directory. (The command is a Python script that takes as input all
files in the target directory.)

This was working fine for weeks. My sysadmin says nothing has changed
in the webserver or php installation.

If anyone has *any* insights as to why exec() would just stop working,
*please* respond here; this is holding up a critical project!

Thanks much,
Rick

Apr 30 '07 #1
1 3924
On Apr 30, 5:36 pm, rickcasey <caseyr...@gmail.comwrote:
I wonder if anyone has experienced something like this, as it seems
truly bizarre and is causing me to tear out my hair (what little there
is left of it)....

The exec() function just suddenly stopped working, for no discernable
reason. Here is the code:

$execdir = $homedirectory."/".$genename."/".$rundir;

// Run the Python script on the Exported text file(s).
$cmd = "/home/ehringer/MAELab/bin/Parse_AD_Output.py --FinalCall ".
$execdir;

$debug = 0;
if ($debug) {
echo "<brcmd = ".$cmd."<br>";
}

echo "<h3>Difference Report for Project: ".
$projectname."&nbsp;&nbsp;&nbsp;&nbsp;Gene: ".
$genename."&nbsp;&nbsp;&nbsp;&nbsp;SNP: ".$snpname."</h3>";
// echo the selected filenames here as a record:
echo "<h4>Files compared in this run:<br>";
foreach ($filename_arr as $file) {
echo $file."<br>";
}
echo "</h4>";
echo "<button onclick=\"location.href='saveTempDiff.php?cmd=".
$cmd."'\" >Save As Temp Comparison File</button>&nbsp;";
echo "<button onclick=\"location.href='saveFinalDiff.php?cmd=".
$cmd."&gene=".$genename."&snp=".$snpname."'\" >Make Final Calls</
button>&nbsp;";
echo "<input type='button' onClick='location.href=\"selectProject.php
\"' value='Select Projects' class='btn'>&nbsp;";
echo "<button onClick='location.href=\"logout.php\"'><button>Log out</
button><br>";
echo "<pre>";
// Now execute the PHP function that runs an external program and
capture the output
// in an array.
exec($cmd,$output,$rtnvar);
if ($rtnvar) {
foreach ($output as $var) {
if ( (strcmp("seen before!!",$var)==0) || (strpos($var,"CALLS")>0))
{
continue;
}
echo $var."<br>";
}
} else {
echo "<h3>Execution of Parse_AD_Output failed!</h3><br>";
}
echo "</pre>";
?>

If I set debug true, and output the cmd variable, I can cut-&-paste
the cmd, and it executes fine at the command line in the target
directory. (The command is a Python script that takes as input all
files in the target directory.)

This was working fine for weeks. My sysadmin says nothing has changed
in the webserver or php installation.

If anyone has *any* insights as to why exec() would just stop working,
*please* respond here; this is holding up a critical project!

Thanks much,
Rick
I dont believe nothing has changed!
functions can be prevented from being used in the php.ini using
disable_functions = exec
for instance.

When you say stopped working, does it just not return anything, is it
the call to exec which is not happening or the output from your
script. Try using &2>1 to redirection the errors

Is there no chance of using passthru or system instead?

has there been any system wide security changes? has the kernel on the
machine change over to secure Linux,
are there simply no errors outputted form the php script at all?

Thats all I have right now.

Apr 30 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by SM Ryan | last post: by
14 posts views Thread by Hemanth | last post: by
6 posts views Thread by Hal Vaughan | last post: by
23 posts views Thread by Maarten | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.