Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running Perl(I'm a beginner) on my shared website 2

Status
Not open for further replies.

Chomauk

Programmer
Jun 8, 2001
130
I have a book(Learning Perl) and I have a web host which supplies the perl interpreter. I have used HTML, CSS, PHP, JavaScript and VBScript so I thought Perl would be easy to learn. However, I am lost so please forgive my potentially stupid questions. I do not understand how to run a Perl script on my website.

I created a file where I copied the code for the "Hello World" program and changed the first line to the line provided by my web host. When I enter the name of the file(hello) in the address box so it will run all I get is a page displaying the code I created!

I do not have Perl on my Windows XP machine as I figured I could do the programming with the editor provided by my web host. Is this correct?

As you can see I need it explained to me in better terms than the book gives and my Web Host won't answer my emails about a little help.

Thanks much
 
Are you getting the source of your perl code displayed on the Host or on your Local System (I am unclear from your problem description)

IF it is on your webhost there could be a few problems:

1) File extension. Some webhosts require you to use .cgi or .pl or some other arbitrary extension. It is this file extension that identifies the perl script as a script to the server. Is your file named appropriately?

2) Some webhosts require that the file be in a specific directory (example: /cgi-bin/). Does your webhost have this requirement?

3) Some webhosts require specific permissions to be set on your perl script in order to execute. Do you have it set to executable?

Finally, can you give us a URL where we can look?

I think the problem is #1 but without more info I can not be sure.
 
Thank you very much for replying!

I do not know if the source of my perl code is displayed on the Host or my Local System(How do I find that out?)

I will answer each of your questions with the number of the question you asked and then my answer(the best I can answer anyway).

1.) I renamed the file hello.pl and got the following error: "CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:
Hello, world!"
My web host does not provide what the extension should be.

2.) I copied the file to the /cgi-bin/ directory and got the same error as above.
My web host does not specify if the file should be located there or not. In their knowledge base the only thing mentioned about Perl is that the Perl interpreter is located in /usr/bin/perl.

3.) I do not know if my webhost requires specific permissions to be set on my perl script in order to execute. I do not know how to set it to be executable.

is the URL.

Here is the code for the Perl script called hello.pl:
#!/usr/bin/perl -w
print "Hello, world!\n";

The only thing my webhost provides concerning Perl is the location of the interpreter and nothing more. I've emailed them three times and they do not answer. Since I purchased their business I have discovered they are not very well reviewed by some of the Host Ratings sites. There have been other issues with them which is another story.

I hope I have provided you with the information you asked for and I really appreciate your taking the time to help me.
 
Save your file in the cgi-bin directory as hello.cgi

Use this, and then try it.

#!/usr/bin/perl -w
print "Content-type: text/html\n\n";
print &quot;<H1>Hello World</H1>\n&quot;;

 
Yea, you just need to print your http headers ad ho11ywood specifies.

You may want to use the CGI object to get full headers out

likes this
-----
#!/usr/bin/perl -w
use CGI;
my $query = new CGI ;
print $query->header
print &quot;<H1>Hello World</H1>\n&quot;;
-----
Many webservers require full request headers, not the abbreviated set that ho11ywood specified. The CGI object will do this automatically.

You sohuld read up on CGI a bit when you get a chance.
 
Good post Siberian. Use the CGI module. It'll help when you continue your web development.
 
Much thanks, siberian and h011ywood! Using the script by h011 worked and I'll proceed to learn up on cgi as you suggested.
 
Please review the FAQs on this site in the Perl and CGI forums... particularly faq452-3023. This will help you with newbie-type problems.

Sincerely,

Tom Anderson
Order amid Chaos, Inc.
 
<script language=&quot;PerlScript&quot;>
$window->alert(&quot;Hello World\n!&quot;)
</script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top