View Full Version : How to use CGI script
I need a random link generator that selects among html files on my directory that I specify.[nbsp][nbsp]I believe this is a job for a CGI script, but haven't used one before and can't find info on how to go about it.[nbsp][nbsp]I've looked on AOTA, and haven't found anything helpful. I know there are a lot of sites offering free CGI scripts, but I need the basics on how to install and use a CGI script on MY FutureQuest site. Can anyone point me someplace that will explain what to do?
------------------
Take care,
KAT, katsmeow.com (http://katsmeow.com)
Hi KAT,
Hearts started a really great beginners tutorial at http://www.heartsweb.com/tutorial/cgi.htm
I think you'll find it to be pretty close to what you are needing.[nbsp][nbsp]If it helps... be sure to toss her a note of thanks.. she was trying very hard to keep the first timer in mind:)
Deb
Thanks. I worked with Heart's tutorial several hours yesterday and am still at it this morning.[nbsp][nbsp]It took me from nowhere, all the way to getting the error message "Cannot open the internet site http://www.katsmeow.com/cgi-bin/rand-link.pl Requested header was not found". Believe me, this IS progress. I've made mistakes at every step and am learning from them.
Now I'm stuck. The first line of the "script" is:
#!/usr/local/bin/perl[nbsp][nbsp]Am I taking things too literally as to what it should be? I.e., should it have my domain name, or FutureQuest in there someplace?[nbsp][nbsp]
I'd appreciate any advice.[nbsp][nbsp]BTW, I have folders cgi-bin in three directories: /big/dom/xkatsmeow/cgi-bin,
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp] "[nbsp][nbsp][nbsp][nbsp] "[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp] " /www/cgi-bin
[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp] "[nbsp][nbsp][nbsp][nbsp] "[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp] "/katsmeow/cgi-bin
I suspect the last two of them shouldn't be there, but at least the one at www/ won't delete.[nbsp][nbsp]I put the cgi file in all three places just in case.[nbsp][nbsp]Also, the cgi file had an extension of tar when I downloaded it. I changed the extension to .pl when I edited it, as the readme file showed the link being to it as .pl.[nbsp][nbsp]Thanks in advance.
Justin
06-30-1999, 03:52 PM
Oh, my... a .tar file is a compressed file - like a ZIP file under Windows or DOS...
What you need to do is uncompress the file - inside it should contain the .pl file you are looking for (and probably a readme and other files).
For info on how to uncompress (or "unzip") the file, see this thread: http://www.aota.net/ubb/Forum3/HTML/000290.html
As for the "shebang line", as it's called, it can be either <font color=#FF0000>#!/usr/bin/perl</font> or <font color=#FF0000>#!/usr/local/bin/perl</font> - either way is fine. It is simply the directory path on the server to the Perl program, not a URL.
The only cgi bin you should have is <font color=#FF0000>/big/dom/xkatsmeow/cgi-bin</font> - the one in your /www directory needs to be deleted before you can use your real cgi-bin... you should be able to delete it with no problems, as well as the one in your home directory, although that one is not web accessible and shouldn't hurt anything other than causing confusion.
Let me know if any of this helps.
------------------
Justin Nelson
FutureQuest Support
Still no luck.[nbsp][nbsp]Hearts was helping for awhile. I had unzipped the file. Just got confused on the loading as text file thing and had changed the extension to .txt.[nbsp][nbsp]It's back to .pl now. I loaded it as a text file, and changed the file attributes to 755. ...Also got rid of the extra cgi-bins.
So, now I have a directory named links in katsmeow/com/cgi-bin. It contains 2 files: rand_link.pl and database (no extension.[nbsp][nbsp]The database file is a list of URL's, one per line, with a comma after each except the last.
The file http://katmeow.com/relmag/rellink.htm contains the link that I think should go to the .pl file.[nbsp][nbsp]However, I'm still getting the error message "Internet Explorer cannot open Internet site http://www.katsmeow.com/cgi-bin/links/rand_link.pl[nbsp][nbsp]The requested header was not found."
Is the browser looking for an HTML tag on the .pl file? Is there some other file needed I don't know about?
This is my first time out with CGI. Please help.[nbsp][nbsp]I have a second set of pages ready to go that also needs the random script generator.[nbsp]
In your rand_link.pl file it says:
# Define Variables
$linkfile = "../www/relmag/database";
# Options
$uselog = 0;[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]# 1 = YES; 0 = NO
[nbsp][nbsp] $logfile = "/home/mattw/public_html/links/rand_log";
It should be:
# Define Variables
$linkfile = "database";
# Options
$uselog = 0;[nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp][nbsp]# 1 = YES; 0 = NO
[nbsp][nbsp] $logfile = "rand_log";
In your database file... there should be no commas after each line.[nbsp][nbsp]You will also want to take out any extra line feeds (extra returns below the last line) at the end of the file.
To make these edits... open the files with a text editor..make the changes and then upload them to the server in ASCII.[nbsp][nbsp]
That should fix it :)
Deb
thanks Thanks THANKS.[nbsp][nbsp]It works![nbsp][nbsp]In case anyone wants to see (a magic way to show off the grandkids) click the link at http://katsmeow.com/relmag/rellink.htm.[nbsp][nbsp]I'll pretty up the link page this week.
------------------
Take care,
[nbsp][nbsp] KAT,[nbsp][nbsp]katsmeow.com
[This message has been edited by KAT (edited 07-14-99)]
vBulletin® v3.6.8, Copyright ©2000-2013, Jelsoft Enterprises Ltd.