Using APACHE with POST command, Parsing File

Using APACHE with POST command, Parsing File

Post by John Re » Sat, 17 Jun 2000 04:00:00



Hi,

I am running Apache on Dec Unix 4.0

I have a Web Page that calls a cgi script and passes a file using the POST
method & ENCTYPE="multipart/form-data"

My script is written in shell and a bit slow.  Is there any utility out
there to take this file & parse it.  It would be brilliant if it would take
the the values passed in single variables & put these to system environment.

If you are unfamilure with the exact config this is what happens.
The web page allows you browse to a file & sent the contents of the file to
the cgi script.  The cgi script gets the contents of the file as STDIN in
text.  Each field on the form is a different MIME field & is seperated by a
boundry
so from the following eg I want to be able to pass the text "SH,2103" to a
variable that I can identify as representing LocationCode the text/plain bit
should go to STDOUT or a file.

The method is brilliant but the code makes it hard to implement many
versions.

I would program it in C, if I knew how to program C!

-----------------------------7d046369c8
Content-Disposition: form-data; name="LocationCode"

SH,2103
-----------------------------7d046369c8
Content-Disposition: form-data; name="UploadFile";
filename="G:\HANDHELD\stmar00.dat"
Content-Type: text/plain

0000000070331,8,000125
0000000089142,2,000125
...
5098982734124,46,000125
0000000052818,25,000125

-----------------------------7d046369c8--
#

 
 
 

Using APACHE with POST command, Parsing File

Post by <bg.. » Sat, 17 Jun 2000 04:00:00



> I am running Apache on Dec Unix 4.0

> I have a Web Page that calls a cgi script and passes a file using the POST
> method & ENCTYPE="multipart/form-data"

> My script is written in shell and a bit slow.  Is there any utility out
> there to take this file & parse it.  It would be brilliant if it would take
> the the values passed in single variables & put these to system environment.

Recent versions of CGI.pm can handle this (and more). Note that
multipart/form-data is meant to be used in situations (file uploads,
large data fields) where environment variables can be unwieldy.

You should be able to get CGI.pm at
         http://www.genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html
         ftp://ftp-genome.wi.mit.edu/pub/software/WWW/

Quote:> The method is brilliant but the code makes it hard to implement many
> versions.
> I would program it in C, if I knew how to program C!

I'm afraid my suggestion requires proficiency in Perl, which you may
or may not have.

In any case, remember that CGI programs are dangerous for the security
of your systems unless they are *very* competently written. That could
be taken to mean "don't do it yourself, hire a specialist"; unfortunately,
not everyone who advertises himself as a competent CGI programmer is one.
Maybe your best course is to (a) hire someone, and (b) learn enough
about it yourself to make an informed judgment on your contractor's
competence.

 
 
 

1. Parsing file sent to Apache using POST

Hi,

I am running Apache on Dec Unix 4.0

I have a Web Page that calls a cgi script and passes a file using the POST
method & ENCTYPE="multipart/form-data"

My script is written in shell and a bit slow.  Is there any utility out
there to take this file & parse it.  It would be brilliant if it would take
the the values passed in single variables & put these to system environment.

I would program it in C, if I knew how to program C!

Anybody doing the same thing to save me re-inventing the wheel or am I
missing a bit in the manual.

   Thanks in advance

    John


2. Linux hot swap support

3. Apache: Parsing XSSI files without using HTTP

4. PROBLEMS WITH MY VIDEO CARD & MONITOR

5. Apache/Solaris slow POSTing large file using enctype="multipart/form-data"

6. Unknown LCD screen

7. Extracting Quake2 dedicated server files

8. Using apache's "ab" : How to write the POST file

9. command-line access to parsed vs. unparsed HTML on Apache

10. Parsing a string using awk/sed/ or unix shell commands

11. Parsing PHP using Apache

12. Parsing a file to generate commands