Solved

Cgi help

Posted on 1997-07-16
4
302 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Fixed div within Bootstrap carousel item 11 54
AWS CLI issues with Tags 3 64
issue with beginner powershell script. 5 54
What is assert.deepEqual? 4 39
Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will learn how to count occurrences of each item in an array.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

910 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now