Connecting Tech Pros Worldwide Forums | Help | Site Map

CGI Script

Member
 
Join Date: Jul 2007
Posts: 35
#1: Jul 3 '08
Hi every body,

i am just new to the CGI scripting.
i am trying to run a basic CGI script . i am using APACHE as my web server .

i have placed my basic script inven.cgi in the web server and when i am trying to access my script with http://mydomain/inven.cgi
instead of getting the functionality of the script , i am seeing the whole script code on the web page.Do i need to do any setting to run the CGI script?

here is the code which i used

Expand|Select|Wrap|Line Numbers
  1. use CGI qw/:standard/;
  2.   print header,
  3.         start_html('A Simple Example'),
  4.         h1('A Simple Example'),
  5.         start_form,
  6.         "What's your name? ",textfield('name'),p,
  7.         "What's the combination?", p,
  8.         checkbox_group(-name=>'words',
  9.                        -values=>['eenie','meenie','minie','moe'],
  10.                        -defaults=>['eenie','minie']), p,
  11.         "What's your favorite color? ",
  12.         popup_menu(-name=>'color',
  13.                    -values=>['red','green','blue','chartreuse']),p,
  14.         submit,
  15.         end_form,
  16.         hr;
  17.  
  18.    if (param()) {
  19.        my $name      = param('name');
  20.        my $keywords  = join ', ',param('words');
  21.        my $color     = param('color');
  22.        print "Your name is",em(escapeHTML($name)),p,
  23.              "The keywords are: ",em(escapeHTML($keywords)),p,
  24.              "Your favorite color is ",em(escapeHTML($color)),
  25.              hr;
  26.    }
  27.  
  28.    print end_html;
  29.  
Thanking you in advance

rajiv07's Avatar
Familiar Sight
 
Join Date: Jun 2007
Location: Chennai
Posts: 141
#2: Jul 3 '08

re: CGI Script


Your script should be inside the cgi-bin directory which is a special directory to run the perl script.

Regards
Rajiv
eWish's Avatar
Moderator
 
Join Date: Jul 2007
Location: Arkansas
Posts: 900
#3: Jul 3 '08

re: CGI Script


Sounds like the server is not setup correctly. Check to make sure that you have enable it to run CGI scripts.

--Kevin
Member
 
Join Date: Jul 2007
Posts: 35
#4: Jul 4 '08

re: CGI Script


Quote:

Originally Posted by eWish

Sounds like the server is not setup correctly. Check to make sure that you have enable it to run CGI scripts.

--Kevin

Exactly..kevin.. i have made the changes.. thannx for you help
Reply