Welcome to WebmasterWorld Guest from 54.196.233.208

Forum Moderators: coopster & jatar k & phranque

Message Too Old, No Replies

IE Opens .pl file instead of executing it

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

New User

5+ Year Member

joined:Apr 26, 2007
posts:2
votes: 0


After I write a simple Helloworld.pl the IE is not executing it, instead it opens a dialog with 'Open' 'Save' option. Wats wrong...?
3:05 pm on Apr 26, 2007 (gmt 0)

Administrator

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

joined:Aug 10, 2004
posts:10542
votes: 8


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...
6:38 pm on Apr 26, 2007 (gmt 0)

Preferred Member

10+ Year Member

joined:Jan 5, 2006
posts:536
votes: 0


and if cgi does not work it means the http server is not setup to execute scripts.
6:47 pm on Apr 26, 2007 (gmt 0)

Senior Member

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

joined:Apr 19, 2002
posts:3171
votes: 8


welcome to WebmasterWorld

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

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

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Mar 29, 2007
posts:1147
votes: 0


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.

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

New User

5+ Year Member

joined:Apr 26, 2007
posts:2
votes: 0


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

Thanks folks!