Solved

Cgi help

Posted on 1997-07-16
4
315 Views
Last Modified: 2013-12-25
I have a html page that contains a call to a cgi perl script. However it seems like the script never get's processed.

This is the html file with permissions -rw-r--r--  :
<HTML>
<BODY>
<H1><B>Inquiry Page </B>
<FORM>
<CENTER>
<FONT SIZE=1+>

<FORM ACTION="http://www.carter.edu/~monish/public_html/cgi-bin/one.cgi" METHOD="POST" >

<TABLE BORDER=10 BGCOLOR=LIGHTBLUE BORDERCOLOR=BLACK CELLPADDING=10 CELLSPACING=20>
<TR>
    <TD>
        <INPUT NAME="NAME" SIZE="20">NAME <BR>  
    </TD>
</TR>
</TABLE>
</FONT>
</CENTER>

<p>
Comments or Questions? Send mail to
<A HREF="mailto:monish\@carter.edu">monish@carter.edu</A>

<p>
To SUBMIT or RESET the Information Request form press the
appropriate button:  

<p>
<INPUT TYPE="SUBMIT" VALUE="Submit">
<INPUT TYPE="RESET" VALUE="Reset">

</FORM>
</BODY>
</HTML>


This is the one.cgi perl script :

#!/usr/local/bin/perl

open(FILE1,">>output") ;
if($ENV{'REQUEST_METHOD'} eq "POST")
{
  read(STDIN,$datain,$ENV{'CONTENT_LENGTH'});
  print $ENV{'REQUEST_METHOD'} ;
  print FILE1 " Testing \n" ;
  print FILE1 "\n$datain\n" ;
  close(FILE1) ;
}
else
{
  print FILE1 "NOPOST \n" ;
  close(FILE1) ;
}

The permissions of cgi-bin director are open(FILE1,">>output") ;
if($ENV{'REQUEST_METHOD'} eq "POST")
{
  read(STDIN,$datain,$ENV{'CONTENT_LENGTH'});
  print $ENV{'REQUEST_METHOD'} ;
  print FILE1 " Testing \n" ;
  print FILE1 "\n$datain\n" ;
  close(FILE1) ;
}
else
{
  print FILE1 "NOPOST \n" ;
  close(FILE1) ;
}

The permission of cgi-bin directory is  drwxr-xr-x
and the permissions of one.cgi script is -rwxr-xr-x

The html page loads up fine but after entering data in the table and clicking on submit the creation of the "output" file does not take place ???? However, if I just run one.cgi "output" gets created and contains "NOPOST" text.

What's going on here ? Why does the web-page not create an output file ?
0
Comment
Question by:monish
  • 2
4 Comments
 
LVL 7

Accepted Solution

by:
faster earned 10 total points
ID: 1829128
Besides all the work you listed, normally there is one more thing: to config the cgi directory in your web server.  Have you done that?
0
 

Author Comment

by:monish
ID: 1829129

Yes the sys. admin tells me that I should be able to run cgi scripts from my home directory.
0
 
LVL 7

Expert Comment

by:faster
ID: 1829130
I think it must be one of the following reason:

Your url is incorrect, your web server is really correctly configured, perl is not installed on the web server or perl is installed in the directory appear in your script.
0
 
LVL 5

Expert Comment

by:julio011597
ID: 1829131
Who is the owner of directory 'cgi-bin'... i bet it's _you_.

If so, think that the cgi is run by the web server, so the cgi runs as user 'web' or 'nobody' or whatelse the web server is, and the 'web' user is _not_ allowed to create a file in your directory.

Solution?

1. chmod 777 cgi-bin, which would be very unsafe, since anybody on your system could put 'bad' things in your _cgi_ directory;
2. if possible, create yourself an empty 'output' file and give it wright permissions - maybe, the best solution;
3. let the one.cgi write its file in a (777) directory other than cgi-bin, so that, at least, an executable file put there won't be runnable through the web.


HTH, julio

P.S. if this is the answer, would you please let me submit it as an answer to get graded?.. thanks :)
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question