Home Lesson 2: Running your script-it's a good exercise

Here is how you run a script:

1) Save it as a text file (for example: "test.cgi")
2) Go to the command promt.
3) If you are on a unix system, then you may have to type "chmod 755 test.cgi" where test.cgi is your file name.
4) Type the file name ("test.cgi")
5) It should run. If it doesn't, then your program may have errors in it.

Check to make sure that there aren't any. Also make sure that you have #!/usr/local/bin/perl as the first line. If it still doesn't work, then make sure that you have Perl installed on your system.

If you have tested your script and it does what you wanted it to, then you are ready to see if it will work over the internet.


Here's how to check your Perl Program to see if it'll work on the net:

1) You have to have access to some sort of web servers or provider. If you're not sure if you do, then you probably don't. Check our homepage list. (???)
2) Contact your server administrator to find out if you are allowed to run Perl scripts on their server. If you can, then follow his instructions. They vary from system to system.
3) After you have followed the instructions, you can call the script from a homepage. Simply put a hypertext link to your script. For example:

Click here!

4) One thing that you have to have in order for the web browser to work right is one command in your script:

print "Content-type: text/html \n\n";

All you have to do is add this line into your script before you output any text to the browser. It just tells the browser that it is looking at html, not any other type of information, like an image.

Chapter 1: $trings-they'll throw you for a loop Home Chapter 3: Program Control-so who's really in charge?


<<< Chapter 1 | Home | Chapter 3 >>>