For Programmers: Free Programming Magazines  


Home > Archive > PERL CGI Beginners > November 2005 > activating CGI









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author activating CGI
bahhab@hotmail.com

2005-11-21, 7:55 am

Hello

If I run the cgi script below in a terminal window under my user name
it works fine and all three files (ann1.res ann2.res and ann3.res) are
created. But if I call it through an apache served web page only
ann2.res (from the touch command) is created and the error file has one
line...

[tmp]# more cgi_error.txt
cp: cannot stat `/tmp/ann3.res': Permission denied
[tmp]# ls -l ann3.res
-rwxrwxrwx 1 fly fly 14427 Nov 21 14:08 ann3.res

I don't think it is a file permissions problem because I've chmod 777
on everything trying to get it to run. It may be that there is
something missing in the httpd.conf file (relevant parts quoted below)
but I have that set up the same as one on a server that is working.

So what am I missing? Any help much appreciated.

Thanks
Ann

<cgi script>

#!/usr/bin/perl
BEGIN {open (STDERR, ">/tmp/cgi_error.txt");}

use CGI qw(:standard);

$cmd1="/usr/ncbi/blastall -p blastn -e 0.0001 -d
/var/www/html/butterfly/db/files/db/Heliconius_db.fsa -i
/tmp/_HEC00002.fsa -o /tmp/blast/ann1.res -v 10 -b 10 -m 0";
system ($cmd1);

$cmd2="touch /tmp/blast/ann2.res";
system ($cmd2);

$cmd3="cp /tmp/ann3.res /tmp/blast/.";
system ($cmd3);

print header(-type=>'text/html', width=>'200', height=>'200');
print "<br><font size=+4>All Done</font></b></center><br>";
end_html();

<httpd.conf>

LoadModule cgi_module modules/mod_cgi.so

# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the realname directory are treated as applications and
# run by the server when requested rather than as documents sent to the
client.
# The same rules about trailing "/" apply to ScriptAlias directives as
to
# Alias.
#
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

# To use CGI scripts outside of ScriptAliased directories:
# (You will also need to add "ExecCGI" to the "Options" directive.)
#
<Directory "/home/*/public_html/cgi-bin">
Options ExecCGI
SetHandler cgi-script
</Directory>
AddHandler cgi-script .cgi

<Directory "/var/www/cgi-bin">

Options ExecCGI

AllowOverride None

Allow from all

Order allow,deny
</Directory>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com