...

View Full Version : Reading & writting a file in perl/cgi and executing it in apache webbrowser



sivasankar
08-17-2009, 07:05 AM
hi every body,

I am trying to execute system command and open a file to read and right in apache web browser using perl/cgi scripting and the code is as follows.



#!/usr/bin/perl
print "Content-type:text/html\n\n";
@var=`ls -tr /var/lib/php/session/`;
open(FILE,"/var/lib/php/session/$var[$#var]") or die $!;
$filename=<FILE>;
close(FILE);
print "File Name :: @var <br>";
print "File Name: $filename <br>";


If i execute the above code in normal perl program i mean perl <filename> it's executing without any error but if i am trying to execute through apache web browser i am getting the following error in http errorlog


[Thu Aug 13 11:28:57 2009] [error] [client 59.163.89.119] ls:
[Thu Aug 13 11:28:57 2009] [error] [client 59.163.89.119] /var/lib/php/session/
[Thu Aug 13 11:28:57 2009] [error] [client 59.163.89.119] : Permission denied
[Thu Aug 13 11:28:57 2009] [error] [client 59.163.89.119]
[Thu Aug 13 11:28:57 2009] [error] [client 59.163.89.119] Permission denied at /var/www/cgi-bin/kkkkk.pl line 4.


and in browser it showing 512 error for the system command any idea about this error.

Thank in advance.

shyam
08-17-2009, 01:50 PM
does the user that apache is running as have execute privileges on that directory?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum