Re: CGI scripts

Anselm,
        
The attributes used for the resource fup.cgi are as follows:

        Identifier:     fup.cgi
        quality:        1
        content-type:   text/plain
        putable:        false
        command:        /home/jokoro/Jigsaw/Jigsaw/WWW/cgi_bin/fup.cgi
        noheader:       false
        generates-form: false

        (all others except last-modified have been left blank, and no filters 
        have been added).

Below is the contents of the CGI script it is located in the "/WWW/cgi_bin" 
directory along with the needed Perl library (cgi-lib.pl).  The Perl interpreter
itself is included in the PATH environment variable.

Contents of fup.cgi:
        
        #!/usr/local/bin/perl4

        # Copyright (c) 1996 Steven E. Brenner
        # $Id: fup.cgi,v 1.2 1996/03/30 01:35:32 brenner Exp $


        require "./cgi-lib.pl";

        # When writing files, several options can be set... here we just set one
        # Limit upload size to avoid using too much memory
        $cgi_lib'maxdata = 50000;


        # Start off by reading and parsing the data.  Save the return value.
        # We could also save the file's name and content type, but we don't
        # do that in this example.
        $ret = &ReadParse;


        # A bit of error checking never hurt anyone
        &CgiDie("Error in reading and parsing of CGI input") if !defined $ret;
        &CgiDie("No data uploaded",    
                "Please enter it in <a href='fup.html'>fup.html</a>.") if !$ret;


        # Munge the uploaded text so that it doesn't contain HTML elements
        # This munging isn't complete -- lots of illegal characters are left
as-is.
        # However, it takes care of the most common culprits.
        $in{'upfile'} =~ s/</&lt;/g;
        $in{'upfile'} =~ s/>/&gt;/g;


        # Now produce the result: an HTML page...
        print &PrintHeader;
        print &HtmlTop("File Upload Results");
        print <<EOT;

        <p>You've uploaded a file.  Your notes on the file were:<br>
        <blockquote>$in{'note'}</blockquote><br>
        <p>The file's contents are:
        <pre>
        $in{'upfile'}
        </pre>
        EOT           
        
        print &HtmlBot;

            
A little long, but hopefully this information will be helpful in finding the
problem.

thanks,
John Okoro.


At 08:11 PM 7/24/96 PDT, you wrote:
>John Okoro writes:
> > Hello everyone,
> > 	I have been trying to use a CGI script written in Perl to implement
> > form based file upload to jigsaw.  I have tried using a CgiResource to
> > wrap the script for use on the jigsaw server as outlined in a previous
> > archived message.  The script is called fup.cgi (the same name was used
> > for the resource), and it is called as the action for an HTML form
> > (action='.../cgi_bin/fup.cgi').  
> > 	However when I use the form to run the CGI script I receive the same
> > error message (*Cgi error unable to parse script headers*) no matter
> > what modifications I make to the resource.  The script does work from
> > the command line.  If anyone else has encountered such an error, or has
> > any ideas on where I might have gone wrong, I would appreciate any
> > suggestions.
>
>It looks like your script headers are invalid. The CgiResource tries
>to parse the following headers (if present):
>- status
>- content-type
>- location
>I don't remember now, but i beleive at the time I implemented the
>stuff I was reading the spec. If you give the beginning of what your
>script produces, I might be able to help...
>
>Anselm.
>
>

Received on Thursday, 25 July 1996 13:39:06 UTC