CGI not working.....

  • Katushai
  • Graduate
  • Graduate
  • User avatar
  • Posts: 152

Post 3+ Months Ago

need help!!!.....when i make a Perl script, it works in the terminal, but when i code it as a cgi, save it as a .cgi, put it in cgi-bin and open it in mozilla it just doesnt work...it shows the actual code. so i went to the books and looked up why and it didnt make any sense.....can somebody help please???thanks...late
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

My first guess is it sounds to me like your cgi-bin doesn't have execute permissions. Do you have the ability to CHMOD your cgi-bin to 755 or 777?
  • Katushai
  • Graduate
  • Graduate
  • User avatar
  • Posts: 152

Post 3+ Months Ago

well i typed chmod 755 /home/blaine/cgi/perl/first.cgi and then moved it to cgi-bin.....should i have moved it to cgi-bin first? lol i probably sound like a total n00bert right now....well i am :wink:
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

Sorry Katushai -- I'm totally not following you on this. I think permissions on the execute is your problem, but I can't for the life of me decipher what you're doing. Please provide more specific details. There are others here (like Bigwebmaster for example) who are pretty well-versed in perl but it's hard to follow what you are doing.
  • Katushai
  • Graduate
  • Graduate
  • User avatar
  • Posts: 152

Post 3+ Months Ago

ok let me explain exactly how im goin about doing all this...here it is. i wrote a small program and named it first.pl
Code: [ Select ]
#!usr/bin/perl
print "Content-type:text/html\n\n";
print "<html><head><title>test page</title></head>\n";
print "<body>\n";
print "<h2>testing 1 2 3</h2>\n";
print "</body</html>\n";
  1. #!usr/bin/perl
  2. print "Content-type:text/html\n\n";
  3. print "<html><head><title>test page</title></head>\n";
  4. print "<body>\n";
  5. print "<h2>testing 1 2 3</h2>\n";
  6. print "</body</html>\n";

now that i have this program first.pl saved in /home/blaine/cgi/perl folder, i go to text mode on linux and save it as .cgi.....then i type chmod 755 /home/blaine/cgi/perl/first.pl
and chmod it. then i move it to /var/www/cgi-bin and try to run it as a webpage...and it just shows the code.
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9090
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

There are a few problems that can cause what you are experiencing. First if your server doesn't have a CGI handler for .cgi files it will not know that its supposed to be a Perl Script. So what you can try doing is leaving the extension as .pl first since by default Apache usually has a handler for .pl files.

If the .pl works and you really want it to work so that .cgi works as well, then you need to edit your httpd.conf file and uncomment the following line:

Code: [ Select ]
AddHandler cgi-script .cgi


Once you uncomment that line you need to restart the httpd daemon. You can usually do that by typing:

/etc/rc.d/init.d/httpd restart
  • Katushai
  • Graduate
  • Graduate
  • User avatar
  • Posts: 152

Post 3+ Months Ago

ok...now when you say uncomment that line, you mean take the # off the front of it right?
  • Katushai
  • Graduate
  • Graduate
  • User avatar
  • Posts: 152

Post 3+ Months Ago

this is what it said when i went to restart httpd...

Code: [ Select ]
[root@babyhuey root]# /etc/rc.d/init.d/httpd restart
Stopping httpd:                      [FAILED]
Starting httpd: (98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
                              [FAILED]
[root@babyhuey root]#
  1. [root@babyhuey root]# /etc/rc.d/init.d/httpd restart
  2. Stopping httpd:                      [FAILED]
  3. Starting httpd: (98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
  4. no listening sockets available, shutting down
  5.                               [FAILED]
  6. [root@babyhuey root]#
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9090
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

Type:

/etc/rc.d/init.d/httpd stop

and let it wait for a sec. Then type that again and see if it says failed. Sometimes the process didn't get completely stopped before it started back up which will prevent it from starting since there is something already using port 80. So after you type that command above a few times then you can type the following command to start httpd daemon back up:

/etc/rc.d/init.d/httpd start
  • Katushai
  • Graduate
  • Graduate
  • User avatar
  • Posts: 152

Post 3+ Months Ago

ok it stopped but now its not starting back up...do i have to stop something else before i can start httpd? btw, im running the gui right now.....
  • Flaze
  • Newbie
  • Newbie
  • Flaze
  • Posts: 12

Post 3+ Months Ago

i had that problem before, its your extension application, u need the .cgi extension or .pl also if its a windows server 2003 (which i am running), it has more permission to configure

Post Information

  • Total Posts in this topic: 11 posts
  • Users browsing this forum: No registered users and 55 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.