Welcome to WebmasterWorld Guest from 54.196.175.173

Forum Moderators: coopster & jatar k & phranque

Message Too Old, No Replies

IE Opens .pl file instead of executing it

     

athirukk

9:35 am on Apr 26, 2007 (gmt 0)

5+ Year Member



After I write a simple Helloworld.pl the IE is not executing it, instead it opens a dialog with 'Open' 'Save' option. Wats wrong...?

phranque

3:05 pm on Apr 26, 2007 (gmt 0)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



it's not being recognized as a cgi script.
try renaming it to helloworld.cgi and see if that's enough to make it work...

perl_diver

6:38 pm on Apr 26, 2007 (gmt 0)

5+ Year Member



and if cgi does not work it means the http server is not setup to execute scripts.

topr8

6:47 pm on Apr 26, 2007 (gmt 0)

WebmasterWorld Senior Member topr8 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



welcome to WebmasterWorld

IE doesn't execute scripts!
a web server does, have you got a web server set up?

Dabrowski

10:17 pm on Apr 26, 2007 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



Assuming your server does execute Perl correctly, you'll need to tell the browser what type the file will be. You can do this in the script, by adding a mime-type definition before you start your html output.

You can tell if it's the server or the browser, use IE, download the script. Now, if the contents of the file is the actual script, then it's a server issue, if it contains the script output, i.e. the HTML code for your Hello World script, then the server has executed the script and likely you need the mime-type.

Try this:

print <<END_HTML;
Content-type: text/html;

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
<title>Hello World!</title>
</head>

<body>
<p>Hello World!</p>
</body>

</html>
END_HTML

Without the mime-type the browser doesn't know that it's a HTML file. FF probably takes a guess, but it's only a guess. For instance, 'application/pdf' would be a PDF file, so IE would know to open it with Adobe. As IE doesn't recieve a known mime-type, it assumes it's something it can't handle, so prompts you to download the file instead. It should only download the output though as I described above.

Note the blank line between the mime-type and the HTML DTD? Very important. That bit tells the browser it's the end of the headers, and the start of the file content.

Let us know how you get on.

athirukk

9:20 am on Apr 27, 2007 (gmt 0)

5+ Year Member



Yes...its started working after I changed the Content-type from "Content-type: text/plain" to "Content-type: text/html".

Thanks folks!

 

Featured Threads

Hot Threads This Week

Hot Threads This Month