system(), exec() only partially runs script and returns 0.
Posted: Wed Jun 10, 2009 3:38 pm
Hey all, I've spent the past few days trying to figure out how to get a Perl scripts and Batch commands to work properly from PHP. That is I've tried system(), exec(), and passthru().
Basic ones like "dir" work fine.
Either the script doesn't execute at all or it only executes and prints part of the script.. Here is a specific example. I'm running XAMPP, so I have PHP, MySql, and Apache.
On loading the PHP page part of he script will execute, I know so because the attatched code snippet succesfully copies a file and creates another one in addition to the copied one.
The print statement before the for loop prints as well, but the print statement in the for loop doesn't. It just seems like the execution of the code stops there.
I get a "0" returned from the call to system() as well. It seems like the script partially executes, fails and then returns 0.
Thanks ahead of time for the assistance.
Basic ones like "dir" work fine.
Either the script doesn't execute at all or it only executes and prints part of the script.. Here is a specific example. I'm running XAMPP, so I have PHP, MySql, and Apache.
On loading the PHP page part of he script will execute, I know so because the attatched code snippet succesfully copies a file and creates another one in addition to the copied one.
The print statement before the for loop prints as well, but the print statement in the for loop doesn't. It just seems like the execution of the code stops there.
I get a "0" returned from the call to system() as well. It seems like the script partially executes, fails and then returns 0.
Thanks ahead of time for the assistance.
Code: Select all
<?php
$command = 'test.pl';
$myOutput = system($command, $rc);
echo "$rc";
echo "<pre>".$myOutput."</pre>";
?>Code: Select all
use File::Copy;
#Read in file and print to command line
$infFile = "oemsetup.inf";
open(INFO, $infFile);
@lines = <INFO>;
close(INFO);
$infTable = "id2.csv";
$valid = "valid_PCI";
open(INFO,$infTable);
@table = <INFO>;
close(INFO);
open VALID, ">$valid.csv";
@table2=@table;
open NEW, ">pciENTRY.csv";
$table2[0] =~ s//,Projects,CO,DeviceDesc/;
$found=0;
for($counter=1;$counter<@table2;$counter++){
$table2[$counter] =~ s//,/;
}
[color=#FF0040]print "made it to here \n";[/color]
#Code stops working here, no error message, just doesnt execute onward.
foreach $line (@lines){
[color=#FF0000]print "this won't print \n";[/color]
local($VID, $tVID,$SSID,$tSSID);