Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Cgi help

Posted on 1997-07-16
4
Medium Priority
?
340 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 20 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Suggested Courses

926 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