Solved

Cgi help

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Ned Perl Snippet to Read Files in Directory 5 69
Powershell / new-object PSObject rows 2 348
Linux Scripting 3 121
Need a good Angular tutorial 5 81
Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

776 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