MattGarner

Active Member
Apr 22, 2016
29
3
53
United Kingdom
cPanel Access Level
Root Administrator
Hi all,

Could anyone shed some light on where I'm going wrong here?

So inside /public_html/cgi-bin/ there is a folder called test. In that folder there is a .pl script that contains the following:

Code:
#!/usr/bin/perl
print "Content-type: text/html\n\n";
open (TEST, ">>/home/$username/public_html/cgi-bin/test/test.txt");
print TEST "hello world\n";
close (TEST);
print "Script finished. Check if file exists.";
When you visit the .pl script in the browser - The test.txt file isn't created. Although running the script as root on SSH does make script create the file.

Can anyone help with what is going wrong?
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,295
1,273
313
Houston
Hello,


Have you checked the Apache error logs for references to the script when attempting to execute it? By default they're located at:

/usr/local/apache/logs/error_log
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,295
1,273
313
Houston
Hi @MattGarner


I did try this on a test server and found that through the browser I experienced the same behavior. The script executes without issue but does not create a file. I also found that running this via CLI as my user works without issue as well. I would assume if this is the same behavior you're exhibiting that the issue is in the coding of the script itself as there is no error output to the apache error logs that would indicate it was running incorrectly.


You might also want to seek assistance with the creation of the script:

System Administration Services | cPanel Forums
 

MattGarner

Active Member
Apr 22, 2016
29
3
53
United Kingdom
cPanel Access Level
Root Administrator
Hi @MattGarner


I did try this on a test server and found that through the browser I experienced the same behavior. The script executes without issue but does not create a file. I also found that running this via CLI as my user works without issue as well. I would assume if this is the same behavior you're exhibiting that the issue is in the coding of the script itself as there is no error output to the apache error logs that would indicate it was running incorrectly.


You might also want to seek assistance with the creation of the script:

System Administration Services | cPanel Forums
I'm not all that clued up on Perl - Just trying to help someone out. But it seems it's a permissions problem as when the test folder is given 777 and then you try and run the script via the browser the file is then created owned by "nobody". I assume that it can't be dune without 777 or something on the lines of that? Or the code of the perl script is bad.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,904
2,219
463
I'm not all that clued up on Perl - Just trying to help someone out. But it seems it's a permissions problem as when the test folder is given 777 and then you try and run the script via the browser the file is then created owned by "nobody". I assume that it can't be dune without 777 or something on the lines of that? Or the code of the perl script is bad.
Hi Matt,

Can you verify if the Apache suexec module is installed? If so, you will see output like this:

Code:
# rpm -qa|grep suexec
ea-apache24-mod_suexec-2.4.33-4.4.2.cpanel.x86_64
If not, try installing the suexec module to see if it makes a difference:

Code:
yum install ea-apache24-mod_suexec
Thank you.