PHP includes To: Perl

They have: 101 posts

Joined: Apr 2003

hey guys

i got a perl script that i want to run from my php website, any ideas how?

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

What kind of perl script?

You could try using passthru().

They have: 101 posts

Joined: Apr 2003

a .pl one?

They have: 101 posts

Joined: Apr 2003

the program can be found here:
http://www.scriptarchive.com/ssi_image.html

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

Ya, try passthru().

I asked what kind because some perl scripts require information from Apache. Using the passthru(), the perl script won't have access to the Apache environment. In this case, it shouldn't be a problem.

Mark Hensler
If there is no answer on Google, then there is no question.

They have: 101 posts

Joined: Apr 2003

dosen't work

i tried it...

They have: 447 posts

Joined: Oct 1999

try passthru('/usr/local/perl /full/path/to/script.pl');

if that doesnt work try to execute it from a shell and see if the script is working.

They have: 101 posts

Joined: Apr 2003

oh i used double quotes " is taht okay or single quote it?

They have: 447 posts

Joined: Oct 1999

although you *should* only use double quotes if your string contains variables, it should work either way.

They have: 101 posts

Joined: Apr 2003

didn't work.

Earlier befor i moved on to php i was using SSI on the same server, i couldnt exec a perl or php script. When i used php i can exec php scripts but still not perl scripts... any ideaS?

They have: 447 posts

Joined: Oct 1999

oh duh, perl is at /usr/bin/perl (not /usr/local/perl). my bad.

try passthru('/usr/bin/perl /full/path/to/script.pl');

and make sure perl is actually there, sometimes it's at /usr/local/bin/perl

to test perl from php you can make a test script like so:

<?php
<pre>
echo `
/usr/bin/perl -v`;
</
pre>
?>

you should get something like this: http://anglerschat.com/test.php

They have: 101 posts

Joined: Apr 2003

tried:

passthru('/usr/bin/perl/public_html/cgi-bin/script.pl');

Dosent work!!

and yeah i get a similar test page to the link you provided me with

They have: 447 posts

Joined: Oct 1999

oh, you need a space in there between the path to perl and the path to the script

passthru('/usr/bin/perl /public_html/cgi-bin/script.pl');

They have: 101 posts

Joined: Apr 2003

k i will try thanks Smiling

They have: 101 posts

Joined: Apr 2003

Nope!!!!!!!

They have: 447 posts

Joined: Oct 1999

well i'd guess this script doesnt work. does it work from a shell?

or you can try:

<?php
echo `/usr/bin/perl /public_html/cgi-bin/script.pl`;
?>

and see if it's spitting out any errors.

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

You need the full system path to the file.

passthru('/usr/bin/perl '.$DOCUMENT_ROOT.'/public_html/cgi-bin/script.pl');

They have: 101 posts

Joined: Apr 2003

Still dosent work.. remember i told you previously tha ti had a problem with SSI includes executing perl/php scripts

So i used php and php includes can exec php scripts but not perl Sad

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

is SSI enabled on your server?

is the perl script reasonable to rewrite in php?

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

Are you sure you have the script configured properly?

They have: 101 posts

Joined: Apr 2003

yup

I got ssi enabled buy i cant execute stuff

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

SSI has nothing to do with PHP or the functionality of the Perl script.

We keep questioning you as to the functionality of the Perl script...
Have you tested it in a terminal? Does it work?
Have you tried to run other Perl scripts? Have any of those been successful?

Mark Hensler
If there is no answer on Google, then there is no question.

They have: 101 posts

Joined: Apr 2003

I had it work befor on a free netfirms server using SSI, but i cant get it to work here using SSI or php

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

That didn't answer any of my questions. I don't care what you had working on another server.

Paths change between servers. Have you made sure that the script is properly configured for use on your current server?

Have you tested this perl script from a terminal on your current server? Did it work?

Have you tested any other perl scripts on your current server? Have any of those worked?

Mark Hensler
If there is no answer on Google, then there is no question.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.