can't make .pl script to run on cgi-bin

alafuente

Verified User
Joined
Jul 6, 2011
Messages
7
Hi,
I have a customer who has the following problem:
he has a .pl script which he located on the cgi-bin folder (Public_html/cgi-bin)
the .pl has 755 permission and the script is called from a php file located in public_html.

All works fine using preview mode for the domain (http://xxx.xxx.xxx.xxx/~user) but when he use the script in www format it doesn't work..

At first I thought it was a path problem.. so I suggested to use the full path 'cgi-bin path /home/username/domains/domainname/public_html/cgi-bin/script.pl';
cause originally on the php file the .pl is call like this:
$prog1='cgi-bin/UU.pl';
$cmd=$prog1;
$exit = exec($cmd);
echo "<pre>$exit</pre>";
echo "<br>$cmd";

Im running out of ideas, i've tried different combinations whith no luck..
what could be wrong? why on preview mode works ok, but using the www is not? i've checked the logs, and I got "not such file or directory" when the program calls the .pl script.. so Im guessing it has to be a permission problem rather than a path problem.. do i have to try with 750 for the .pl script?

thanks in advance for any help!
cheers!
 
Read access/error apache logs for the particular vhost.

Hi,
Thanks for your response.
I've checked the error, it says no such file or directory.. the odd thing is that no matter what path I use.. it only works out in preview mode, not using www.

Very strange.. have any other ideas?

thanks in advance.

regards.
 
OK, I guess I need to clarify some moments:

What script do you trigger in "preview mode"? PHP? or Perl one? If you get an error in PHP script, post here the full text of it. Of course you can hide real user and domain names.
 
Hi Alex,
Many thanks for your help!!
the webpage is made fully in php, what it triggers in some moment is a .pl script wich receives some variables from php..

so in preview mode, the whole site works and run smoothly.. even when it triggers the .pl (located at the cgi-bin)

There is no problem or error in php, no matter if its in preview mode or www format.. in both cases there are no error, of course, in www when php triggers the .pl there are no error shown, but nothing happens and checking the logs it only says " /xxxx.pl no such file or directory " and this is what is driven me crazy.. cause in preview mode, everything goes fine.. in the logs shows the execution of the .pl

Once more, many thanks for your help.
Regards
 
checking the logs it only says " /xxxx.pl no such file or directory

Where did you see this error? With exec() command you should execute perl script from disc (with local path), not via apache.

Please show output for:

Code:
ls -la /usr/bin/perl

and

PHP:
<?php
print exec('id');
?>

PHP code should be run via apache. Do it from "preview" and direct mode (www).
 
Here are the answers:

"Where did you see this error? With exec() command you should execute perl script from disc (with local path), not via apache."

the error is shown in var/logs/httpd/error_log.

Output for:
ls -la /usr/bin/perl

The output is:
-rwxr-xr-x 2 root root 11380 Jun 13 06:58 /usr/bin/perl

The output for the php you give me are:

In preview mode: uid=48(apache) gid=48(apache) groups=48(apache)
In www mode: nothing. it shows a blank screen.. but in
var/logs/httpd/error_log it says no such file or directory. (as shown in the .jpg attached)


Once More, many thanks to any help..

Regards
 

Attachments

  • command..jpg
    command..jpg
    17.6 KB · Views: 102
check the path in your php program calling the perl program. It looks as if it may be calling it in the main public_html directory and not the public_html/cgi-bin directory.

Jeff
 
@alafuente,

I guess something is miss-configured on your server. Will you send me links to phpinfo() for both cases: preview mode and direct www mode? Is safe-mode enabled for PHP?
 
check the path in your php program calling the perl program. It looks as if it may be calling it in the main public_html directory and not the public_html/cgi-bin directory.

Jeff
Hi Jeff,
Thanks for your concern..

Regarding to your suggestion,
My customer started using
this relative path 'cgi-bin/script.pl'
(it worked in preview mode)
so I've suggested him to use the full path:
'/home/username/domains/domainname/public_html/cgi-bin/script.pl';
(it worked in preview mode also)

but in www.. no luck, no mater if its in full o relative path.. in www format I can't make it work..
Once more, thanks for your concern.
Regards
 
As an addition:

Note: 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.


http://php.net/manual/en/function.exec.php

And you've got:

safe_mode_exec_dir no value


So, you might want to disable safe_mode on directadmin page.
 
Back
Top