Forum Moderators: coopster & phranque

Message Too Old, No Replies

Running Perl locally

Perl is installed, but cannot be used from Internet Explorer

         

gsx

2:46 pm on Jul 15, 2002 (gmt 0)

10+ Year Member



I have recently installed Perl and have written some CGI/Perl scripts. These work great from the webserver, but on the local version on my hard disk I get a download message from Internet Explorer. I have experimented with changing the file type variables by changing CGI file content type (MIME) to plain/text and it now shows as plain text in the browser instead of the download message. Exactly as you would expect.

What do I need to change the types to in order to get Perl to run on my local machine? Is it possible to run Perl through Internet Explorer or Netscape?

Knowles

2:50 pm on Jul 15, 2002 (gmt 0)

10+ Year Member



How are you putting the file path into the browser? The download effect often happens when you put in C:\filepath\file.cgi. Have you made sure you have a webserver as well? You should be able to type [localhost...] or where ever it is in the dir. Make sure it is in the right dir though.

Brett_Tabke

2:52 pm on Jul 15, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Very nice topic. Many people are would like to do the same gsx.

Let's start here:

What webserver are you running on your local box?
Is it known to work good?

amoore

2:55 pm on Jul 15, 2002 (gmt 0)

10+ Year Member



You can't run perl (or any other CGI scripts) in your browser. The webserver actualy runs it. That means that you have to always use a webserver to run your CGI scripts. You can do this by hitting your local webserver with a URL like [localhost...] or use your machine's real name: [mydesktop.example.com...] . If you use a path like file:///home/username/public_html/foo.cgi or file:///C:/foo.cgi there is no webserver involved to run the CGI script. You're just using the browser as a file browser.

Hope it helps.

-Andy

gsx

3:03 pm on Jul 15, 2002 (gmt 0)

10+ Year Member



I don't have a webserver. What I have is a stand-alone machine with ActivePerl installed. I also have the DzSoft Perl editor.

When I installed both of these, some time ago, I am sure IE version 5 would run Perl scripts. I have since upgraded to version 6 of IE and this will not run the scripts.

This [localhost...] some of you have mentioned: what is this and how can it be set up? Can I get software to emulate a webserver on my local machine?

And yes, currently I am using file:... to access the files, but [localhost...] does not work. I would expect a directory listing of some sort if it were set up on my machine, but I get page not found.

P.S. Have you all been sat waiting for my post today, because these responses have been a bit quick :)

Knowles

3:17 pm on Jul 15, 2002 (gmt 0)

10+ Year Member



You can use ISS or Apache there are alot of others out gsx, you need to have that in order for the scripts to execute.

gsx

3:18 pm on Jul 15, 2002 (gmt 0)

10+ Year Member



OK, I'll try and get one of those, wait for me so I can SHOUT when it doesn't work! :) Thanks for your help.

Brett_Tabke

3:19 pm on Jul 15, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



>emulate

Sure, download the Windows version of Apache. It's pretty easy to install. The tricky part that will take some study is configuring it.

Once you get it working from your browser, and you get to the point of perfect emulation of your website - it will be a religious experience.

Brett_Tabke

3:20 pm on Jul 15, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Shout away - there are many people wishing to do just the same as you. I've helped quite a few here get started.

The ultimate goal, is to perfectly emulate your online/offline stuff. Once you get there, you cut out the "upload and test" step that you have to go through when developing pages. There is little that will boost your productivity than running a local copy of your sites.

gsx

3:27 pm on Jul 15, 2002 (gmt 0)

10+ Year Member



Yes, I like to test my site thoroughly but locally. I don't like to update the site unless I am sure it works.

Like in April, when I had to completely rewrite a shopping basket that collapsed and no-one could order; I could not figure out what was wrong so I started it again, working 20 hour days for around a week.

It also helps you see what other people have to 'put up with' if you use your own site to find products when people phone, however, I don't want to be online all the time or have to wait for a dial in to find my own products!

I have written a Perl search engine (in the smallest sense of the phrase!) to allow users to search for products quickly, rather than the current JavaScript version that works, but is stupidly slow when searching over 1000 products and the user has to download all the description BEFORE the searching even starts!

Brett_Tabke

3:56 pm on Jul 15, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



What webserver are your sites hosted on? That's the one you'll want to install locally. (I'm not much help with the 2s).

gsx

5:53 pm on Jul 15, 2002 (gmt 0)

10+ Year Member



It's on Apache, so that's what I've installed.

I now have it partially working, [localhost...] shows my site, accessing subdirectories now working fine.

The cgi-bin is still the problem. Running a script shows Internal Server Error. Now, I assume the error is because the Perl scripts begin with '#!/usr/bin/perl' and it doesn't know where to look. Can anyone help with this problem?

My local version of Perl is at 'C:\Perl\bin\Perl.exe'.

I obviously do not want to change the first line of code in the .cgi file because it will not work when uploaded to my host. So is there any way around this to force the local variety to a different location than specified in the script?

Brett_Tabke

5:59 pm on Jul 15, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



If perl is on your path, then you can just shorten the shabang line to #!perl. More-than-likely, it will be on your sites online webservers path too and you can just use that.

If not, I would highly suggest reinstalling perl into /usr on your windows box (that's where mine is). It will prevent long term headaches and make off-the-shelf scripts run out of the box.

You might try (I'm not sure about this) just renaming/moving your current install (maybe copy?) to /usr so that the perl.exe ends up as /usr/bin/perl.exe. I don't think there is anything touchy about the perl install in the registery. You probably will also want to put /usr/bin on your path in your autoexec.bat file. example:

path=C:\WINDOWS;C:\WINDOWS\COMMAND;c:\windows\system;c:\usr\bin;

gsx

6:27 pm on Jul 15, 2002 (gmt 0)

10+ Year Member



Right, now my error log reports:

'...[error] [client 127.0.0.1] malformed header from script. Bad header=<html><head><title>...'

I assume it is trying to run the script and getting a response it isn't expeting? Have you seen this before? How do I get Apache to send a header? I have already got in the CGI script to send the content-type and a DOCTYPE information, but it must want something else?

Brett_Tabke

9:58 pm on Jul 15, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



In your httpd.conf file. Turn on all cgi support with the Options directive. I think there is one default line that doesn't include cgi support. What I use:

Options All Indexes FollowSymLinks MultiViews

Then you might want to try a script alias line:

ScriptAlias /cgi-bin /www/foo/cgi-bin

(point the second path to where ever you have cgi's installed)

gsx

1:37 pm on Jul 17, 2002 (gmt 0)

10+ Year Member



OK I have this:

ScriptAlias /cgi-bin/ <local-cgi-bin>
<Directory <local-cgi-bin>>
AllowOverride None
Options Indexes FollowSymlinks MultiViews
Order allow,deny
Allow from all
</Directory>

Where <local-cgi-bin> was too long to put in!

In theory, shouldn't this work? It is in a block which starts with "<IfModule mod_alias.c>". Would this make a difference? Although it was there originally, so I assume it should be in that block.

I've tried the options with the All parameter in and without (as default) and still get server error.

gsx

1:51 pm on Jul 25, 2002 (gmt 0)

10+ Year Member



I've eventually got it to work!

I don't know why it works on my webhost but locally but to sum the problem up, all I needed to do was put linebreaks in the output from the CGI Perl files!

My Content-type:... and <!DOCTYPE... outputs were all on the same line when output (but different lines in the program!)