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

Re:[MacPerl] Testing a local CGI script



CGI is almost exclusively what I use MacPerl for. I think a lot of people on the list use MacPerl for CGI.

The first line #/usr/bin/perl isn't required at all for MacPerl. It's there usually for one of two reasons:
(a) people want the script to work the same on Mac and Unix, and this is required for Unix;
(b) people leave it there just as a reminder they are programming in Perl

Here are basic instructions for the setup for a stand-alone configuration:

Get the latest version of WebStar (commercial, free trial) or MacHTTP (shareware).

Set up your TCP/IP configuration to
- connect via: AppleTalk (MacIP)
- configure: using MacIP manually
- pick an arbitrary (but valid) IP address

Set Appletalk to a valid zone, I use Remote Only.

Make sure AppleTalk is activated.

Launch the server and configure it to recognize the file extension ".cgi" to be type "CGI". The file creator/type can be wildcarded (*).

Create a MacPerl CGI. MacPerl does not save files in this format by default and you have to use "Save as..." to select the file format. Save the file inside the document root of the web server.

Your browser can access the CGI with 
http://[your-ip-address]/[path]/[filename.cgi]
for example
http://205.14.80.95/htdocs/fubar.cgi

This might be on a Mac with the following folder structure:
Macintosh HD:WebStar:MyWebSite:htdocs:fubar.cgi
and WebStar is set up for:
Macintosh HD:WebStar:MyWebSite
to be the document root.

The browser's URLs look just like any other. The web server replaces the slash / with a colon : automatically.

Make sure you use a simple script that works without a doubt, so if you have problems you can fix it by process of elimination. I recommend this script:

#/usr/local/bin/perl
print "Content-type: text/plain\n\n"; #not seen in view source
print "<html><head></head><body>\n"; #not seen in browser window
print "Hello world.<p>\n", scalar localtime, "<p>\n";
foreach $key (sort keys %ENV) { print "<b>$key:</b> $ENV{$key}<br>\n"; }
print "</body></html>\n\n";
# end of program. You don't really need an exit(0).

I recently installed LinuxPPC on half of my hard drive so now I use Linux for most of my CGI work. This has an advantage over MacPerl for me since my main purpose in using MacPerl was for CGIs whose final destination were Unix servers.

If you are going to use a Mac Web server for any significant amount of web traffic, MacPerl may not be your best choice from a performance perspective. But it works great as a learning tool for developing CGI programs that can be tested and ported to Unix without any changes.

MacPerl still has a lot of value to me as a platform-specific scripting language for such things as a front-end for GUI, file operations, and data processing. It's the fastest way to develop GUI for most basic things, without having to compile your own application.

Good luck

Dave



At 6:23 PM 11/11/98, Patrick Beart wrote:
> Folks:
> 
>         Pardon me if this is dealt with in the MacPERL book - I'm obviously
> not to that part, yet. Here goes:
>         I want to (eventually build and...) test a (Mac-)PERL CGI script on
> my local hard drive.
> 
> 1)      What is the mechanism or process to get the Web page to call the
> script?  If the Web page contains the usual "<FORM
> Action="http://www.domain.com/cgi-bin/script.pl" Method="POST">" tag and
> attributes, does this need to be changed for testing purposes to reference
> the local path on my hard drive (I would think so.)?
> 
> 2)      What does the first line of PERL ("/usr/bin/perl" on for UNIX-based
> systems) need to be changed to? I thought that I read somewhere in the docs
> that it could be just "/perl" and MacPERL would pick it up.
> 
> 3)      Anybody do this on a regular basis? (besides Chris!  {G})
> 
>         TIA
> 
> 
> Patrick Beart
> 
> -------------------------------------------------------------------
> patrick@WebArchitecture.com       503-281-4147      Portland, OR
> Web Architecture:   http://www.WebArchitecture.com
> 
> * Founding MEMBER *  Internet Professionals Northwest. (www.ipn.org)
> * MEMBER * Webmaster's Guild/ Association of Internet Professionals
>  -------------------------------------------------------------------
> 
> 
> 
> ***** Want to unsubscribe from this list?
> ***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch



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