LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-03-2010, 11:59 AM   #16
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908

Quote:
Originally Posted by shifter View Post
but the output is always my script registration.cgi:
Okay, do you mean that the server returns the text of your CGI script, and not the output from the running script? If so, then the solution should be easier to track down.

In Debian (and therefore Ubuntu, as I understand it), the Apache2 configuration is divided into individual virtual hosts, and each of these is in the /etc/apache2/sites-available/ directory. In that directory, the default site is defined in default. That is where you should find the CGI configuration elements that you could not find.

You may be able to restart the server with (as root)
Code:
service apache2 restart
--- rod
 
Old 01-04-2010, 09:41 AM   #17
shifter
Member
 
Registered: May 2006
Distribution: Slackware, DragonFly
Posts: 233

Original Poster
Rep: Reputation: 30
Ok, the following block:
Quote:
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
is present in my /etc/apache2/sites-available/default file

My /usr/lib/registration.cgi script is:

Quote:
#!/usr/bin/perl

use CGI;
use CGI::Carp qw(fatalsToBrowser);

my $cgi = CGI->new();

print $cgi->header();

$name = $cgi->param('name');
$surname = $cgi->param('surname');
$address = $cgi->param('address');
$state = $cgi->param('state');
$nickname = $cgi->param('nickiname');
$profession = $cgi->param('profession');
$email1 = $cgi->param('email1');
$email2 = $cgi->param('email2');

open OUTPUT, ">> archivio" or die "Non posso aprire il file: $!";

print OUTPUT "$name|$surname|$address|$state|$nickname|$profession|$email1|$email2\n";

close OUTPUT;

print "Content-type: text/html\n\n";
print "<HTML><BODY><H1>Grazie $name</H1><P><a href='home.html'>Home<a></P></BODY></HTML>";
with

Quote:
<form action="/cgi-bin/registration.cgi" method="post">
in form in /var/www/registration.html, and

Quote:
root@notebook:~# grep registration.cgi /var/log/apache2/*
root@notebook:~#
I typed
Quote:
service apache2 restart
and restarted successfully apache2.

I deleted /var/www/cgi-bin directory to use only /usr/lib/cgi-bin directory.
I double clicked on /var/www/registration.html, compile the form and the web page is firefox with:

Quote:
File not found
Firefox doesn't find /cgi-bin/registration.cgi file.
What is the problem?

Last edited by shifter; 01-04-2010 at 09:52 AM.
 
Old 01-04-2010, 10:07 AM   #18
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
I cannot tell what is the problem, as nothing gets logged from apache. What happens if you go directly to: http://www.domain.com/cgi-bin/registration.cgi
BTW I have tested your script here and it works as expected.
 
Old 01-04-2010, 01:06 PM   #19
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Are you using Firefox as a filesytem browser? That makes the behavior subtly different, as it is not communicating with a web server. It sounds like you are using a Firefox browser on the same host as the the Apache web server, but merely using Firefox as a filesystem browser. Instead, try entering an HTTP URL to attach to the web server:
Code:
http://localhost/registration.html
This will force the referenced file to be fetched with an HTTP GET method, which causes the connection to the Apache server, where the Apache server invokes the CGI. All of this explains why you are seeing the text of the CGI script (apparently; you never did answer my earlier query about that), and not the result of the running script.
Observe the contents of the Apache access and error logs as you do this, and confirm that the URLs are being served by the server.

--- rod.

Last edited by theNbomr; 01-04-2010 at 05:45 PM.
 
Old 01-04-2010, 01:17 PM   #20
shifter
Member
 
Registered: May 2006
Distribution: Slackware, DragonFly
Posts: 233

Original Poster
Rep: Reputation: 30
Ok, peraphs there are progress. Now my web browser message is instruction in my script:
Quote:
Software error:

Cannot open file: Permission denied at /usr/lib/cgi-bin/registration.cgi line 19.
For help, please send mail to the webmaster (webmaster@localhost), giving this error message and the time and date of the error.
Entry in /var/log/apache2 is:
Quote:
[Mon Jan 04 20:13:35 2010] [error] [client ::1] [Mon Jan 4 20:13:35 2010] registration.cgi: Cannot open file: Permission denied at /usr/lib/cgi-bin/registration.cgi line 19., referer: http://localhost/registration.html
Line 19 in /usr/lib/cgi-bin/registration.cgi is:
Quote:
open OUTPUT, ">> archivio" or die "Cannot open file: $!";
How or where I must to open archivio file?

Last edited by shifter; 01-04-2010 at 01:22 PM.
 
Old 01-04-2010, 01:25 PM   #21
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Okay, now it sounds like the server is invoking the CGI, but the CGI is trying to write where it (correctly) has no permission to do so. Use a file in the /tmp directory tree, or somewhere that has write permission.
Code:
open OUTPUT, ">> /tmp/archivio" or die "Non posso aprire il file: $!";
What is showing up in the Apache error and access logs about this?

--- rod.
 
Old 01-04-2010, 05:42 PM   #22
shifter
Member
 
Registered: May 2006
Distribution: Slackware, DragonFly
Posts: 233

Original Poster
Rep: Reputation: 30
Finally it works! Thank you!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with perl ::CGI varala_kanth Linux - Software 0 05-10-2006 03:45 AM
HELP:perl CGI problem supermyself Programming 2 06-12-2005 08:34 AM
CGI -PERL Problem!!! lewkh Fedora 3 05-10-2005 12:19 AM
CGI/Perl problem with SuExec kalbaz Linux - General 2 10-18-2003 06:25 PM
Problem with perl and cgi files JSP Linux - General 1 03-22-2002 08:01 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:03 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration