Perl script not creating file
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:
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?
#!/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?
-
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 0 -
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
Hi Lauren, No entries in the error log by the looks of it.0 -
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: 0 -
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:
0 -
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:# 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:yum install ea-apache24-mod_suexec
Thank you.0
Please sign in to leave a comment.
Comments
5 comments