Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Reading & writting a file in perl/cgi and executing it in apache webbrowser

    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.

    Code:
    #!/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.

  • #2
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    does the user that apache is running as have execute privileges on that directory?
    You never have to change anything you got up in the middle of the night to write. -- Saul Bellow


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •