[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Help with Perl/Browser data transfer



On Fri, 9 May 1997 Chris Nandor wrote
>At 3.25 97/5/9, Angus McIntyre wrote:
>>At 6:13 am +0200 09.05.97, Len wrote:
>>>Just getting started with MacPerl5. I know there has to be a way to run
>>>Perl scripts local using the form tag in html. When I use the POST method
>>>Netscape finds the script, but does not run it. How do I get my scripts to
>>>run local and pass variables from html to Perl as ENV variables, so I can
>>>debug ?
>>
>>It can't be done (as far as I know) unless you're running a Web server on
>>your machine.
>>
>>Your options are basically two:
>>
>>  1. Install a Web server (WebStar, MacHTTP) and access your
>>     pages through that as you would any other Web server
>>  2. Test your scripts separately, feeding them the required
>>     environment variables manually (i.e. by hacking them
>>     into the code of the script temporarily).
>>
>>If I'm wrong about this, I'd be fascinated to hear about it.
>
>You are not wrong.  You can also write your own little server daemon, but
>that would fall under No. 1 above.  And, of course, you would have trouble
>running a server and a CGI at the same time under MacPerl.

A daemon is quite useful to see what the browser is sending back that
should, (but may not), get into %ENV. Here is such a return from MSIE:

POST /first.html HTTP/1.0

Accept: */*, q=0.300

Accept: audio/wav

Accept: audio/x-wav

Accept: audio/aiff

Accept: audio/x-aiff

Accept: audio/basic

Accept: multipart/x-mixed-replace

Accept: text/url

Accept: text/plain

Accept: text/html

User-Agent: Mozilla/2.0 (compatible; MSIE 3.0b1; Mac_68000)

Accept-Language: en

Connection: Keep-Alive

Referer: http://158.152.146.73/second.html

Host: 158.152.146.73

Content-type: application/x-www-form-urlencoded

Content-length: 37



Input-string=Here+is+a+string+to+post



You can run a cgi script from the daemon (in a contorted way) by saying:

MacPerl::DoAppleScript qq(
    tell application "MacPerl"
        Do Script "path:to:script.cgi"
    end tell
);

but that really is only a curiosity. The cgi script cannot pick up
environment variables because there _are_ none (as such) in this situation.


To parse the string in the daemon and pass 'environment variables' across
to the cgi script would be laborious. It would also be pretty pointless
since this is exactly what MacHTTP and the CGI glue do between themselves
anyway.

Alan Fry



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch