Running a Perl script from PHP 
Author Message
 Running a Perl script from PHP

Hi,

I'm close to tearing my hair out here...I am trying to execute a Perl script
from with PHP using:

$command = "/usr/local/bin/perl reconcile -b $storeit -d $thold -f
$fromdate -t $todate";

#system($command, $error);
#exec($command, $output, $error);
passthru($command, $error);

if ($error) {
                print "<PThere was an error reconciling the bill
($error).</P>\n";

Quote:
}

As you can see, I've tried several methods.  I keep on getting the
following:

There was an error reconciling the bill (13).

Can anyone think of why this is happening?  I really cannot find anything to
help me any further.

Thanks for any help you can provide!

Regards,
Raj



Wed, 22 Jun 2005 00:10:38 GMT  
 Running a Perl script from PHP

Quote:

> $command = "/usr/local/bin/perl reconcile -b $storeit -d $thold -f
> $fromdate -t $todate";
...
> Can anyone think of why this is happening?  I really cannot find anything
> to help me any further.

If your provider is running PHP in safe mode you won't be able to do this -
confirm with them that they offer non-safe-mode PHP.

--
----- stephan beal
Registered Linux User #71917 http://counter.li.org
I speak for myself, not my employer. Contents may
be hot. Slippery when wet. Reading disclaimers makes
you go blind. Writing them is worse. You have been Warned.



Wed, 22 Jun 2005 00:41:12 GMT  
 Running a Perl script from PHP


Quote:

> > $command = "/usr/local/bin/perl reconcile -b $storeit -d $thold -f
> > $fromdate -t $todate";
> ...
> > Can anyone think of why this is happening?  I really cannot find
anything
> > to help me any further.

> If your provider is running PHP in safe mode you won't be able to do
this -
> confirm with them that they offer non-safe-mode PHP.

Hi,

It is on a box that I have control over.  I have checked the phpinfo() and
that tells me that safe_mode is "off" for both Local and Master values.

Anything else I can try?

Thanks,
Raj



Wed, 22 Jun 2005 00:59:01 GMT  
 Running a Perl script from PHP

Quote:

>I'm close to tearing my hair out here...I am trying to execute a Perl script
>from with PHP using:

>$command = "/usr/local/bin/perl reconcile -b $storeit -d $thold -f
>$fromdate -t $todate";

>#system($command, $error);
>#exec($command, $output, $error);
>passthru($command, $error);

>if ($error) {
>                print "<PThere was an error reconciling the bill
>($error).</P>\n";
>}

>As you can see, I've tried several methods.  I keep on getting the
>following:

>There was an error reconciling the bill (13).

>Can anyone think of why this is happening?  I really cannot find anything to
>help me any further.

 That's clearly coming from the Perl script - so add debug statements to the
Perl script to make sure it's receiving the expected arguments.

 What is error 13 in the Perl script? Doesn't look like anything to do with
PHP.

 Have you echo'd out the $command? Is it what you expected?

--

http://www.andyhsoftware.co.uk/space | disk usage analysis tool



Wed, 22 Jun 2005 00:58:49 GMT  
 Running a Perl script from PHP
I think we've had this conversation before...


Quote:

> I am trying to execute a Perl script from with PHP using:

> $command = "/usr/local/bin/perl reconcile -b $storeit -d $thold -f
> $fromdate -t $todate";

Notice that you seem to be running a Perl script from a directory
other than cgi-bin.  Consequently, the owner of file 'reconcile'
is most likely a non-root user, which might create problems.  

Quote:
> I keep on getting the following:
> There was an error reconciling the bill (13).

If I remember correctly, Perl's error 13 is an Access Denied error.
So you might try the following:

1. Put 'reconcile' into '/var/www/cgi-bin' or whatever else your
   cgi-bin directory is.  Make sure 'reconcile' is owned by root.

2. Change the command line accordingly:

   $command = "/usr/local/bin/perl /var/www/cgi-bin/reconcile ".
              "-b $storeit -d $thold -f $fromdate -t $todate";

Cheers,
NC



Wed, 22 Jun 2005 13:37:23 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Including Perl scripts in PHP

2. Perl script can't read cookies after PHP output starts

3. Running Lahey Fortran Trial version from a PERL script

4. Run a Perl script within TCL

5. Running perl scripts from tcl

6. Problems running php-script via CGI

7. How do I run shell script from PHP

8. Scheduled Runs of a PHP Script

9. Problem using Sybtcl in web script when Apache is also running PHP

10. Perl CGI Script Invoking Expect Script

11. Does anyone have a perl script (or other method) to convert scripts fro

12. Calling expect script from PHP script

 

 
Powered by phpBB® Forum Software