Solved

Cgi help

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

758 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

19 Experts available now in Live!

Get 1:1 Help Now