cgicgi-bin

How can I read files outside the cgi-bin folder?


I've written a cgi script that processes data that is generated by another program. The problem is that this file is located outside the cgi-bin. How can I make sure that my perl scripts can read this file? I've already tried changing the permissions of this file and I also tried to make a link in the cgi-bin folder but Apache is too smart for that. I guess possible solutions are:

I'm kind of stuck how to do either one of the solutions.


Solution

  • I've solved this problem by using plackup in combination of PSGI.

    use CGI::Emulate::PSGI;
    use CGI::Compile;
    
    my $sub = CGI::Compile->compile("location/to/script.cgi");
    my $app = CGI::Emulate::PSGI->handler($sub);
    

    If you run plackup file.psgi, it sets up a local webserver that runs as the current user. Problem solved.