Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I asked this question at StackOverflow. But I thought I may get a quicker response here.

I have had a webapp using CGI implementation. It basically uses system() calls to launch other programs and the results will be rendered in html. Now, I am trying to implement it using Dancer. In order to run these external programs, I created a "scripts" directory in /MyApp, so it's like /MyApp/scripts. I put all my other scripts there, which will be called in a route handler.
get '/analysis' => sub { if (session('user') && session('logged_in')) { open FH, "<", "./scripts/test.out"; my $msg = <FH>; close FH; chdir ("./scripts"); system("call sth"); #call external programs to generate a "test.pn +g" my $err; copy ("test.png", "../public/images/test.png") || ($err = "cannot +copy"); #copy the "test.png" to public/images directory, so the html +tt can use it my $img = "test.png"; template 'analysis',{msg => $msg, img => $img, err => $err}; } else { return redirect '/' } };
However, I can launch this app successfully as a standalone or using plackup/starman. But I can not deploy it with CGI. I did every step using dancer's doc regarding cgi deployment. I can successfully using cgi to launch dancer's example app. but when I tried to launch my own as above, I always got the error:

app directory '/home/tester/MyApp/bin/..' isn't writable/executable and can't chmod it at /usr/local/share/perl/5.14.2/Dancer/Logger.pm line 16, referer:localhost

It seems a permission problem, but I don't know how to fix it. Is there a better way to launch an external program from route handler? where should I store these external programs, thus they can be executed by the dancer app when it was deployed as CGI. Could anyone help me? Thanks.

Xiaokuan

  • Comment on How to deploy perl dancer app with cgi and calling external scripts?
  • Download Code

Replies are listed 'Best First'.
Re: How to deploy perl dancer app with cgi and calling external scripts?
by Corion (Patriarch) on Dec 30, 2013 at 08:14 UTC

    According to the error message, your problem has nothing to do with the code you've shown. It seems that whatever Dancer::Logger you are trying to use wants to write to /home/tester/MyApp/bin/... The user your CGI program is run as does not seem to have write permissions to that directory.

    You will have to consult with your system administrator on how to remedy that situation, or use a different Dancer::Logger.

Re: How to deploy perl dancer app with cgi and calling external scripts?
by Anonymous Monk on Dec 30, 2013 at 08:22 UTC