LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-02-2013, 06:47 AM   #1
zak100
Member
 
Registered: Jul 2009
Posts: 225

Rep: Reputation: 2
Problem with executing first cgi program


Hi,
I am trying to execute the following cgi program but i am getting error:
Quote:
Not Found

The requested URL /hello.pl was not found on this server.
My cgi program is 'hello.pl':
Code:
[root@HP-UX646UU cgi-bin]# cat hello.pl
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print <<HTML;
<html>
<head>
<title> A Simple PERL CGI </title>
</head>
<body>
<h1> A simple Perl CGI </h1>
<P> Hello World</P>
</body>
HTML
exit;  
[root@HP-UX646UU cgi-bin]#
Its executing from command line:

Code:
[root@HP-UX646UU cgi-bin]# ./hello.pl
Content-type: text/html

<html>
<head>
<title> A Simple PERL CGI </title>
</head>
<body>
<h1> A simple Perl CGI </h1>
<P> Hello World</P>
</body>
[root@HP-UX646UU cgi-bin]#
I am giving following command for execution:
I have also mae it an executable program and stored in cgi-bin directory:

Quote:
[root@HP-UX646UU www]# ls
cgi-bin error html icons manual usage
[root@HP-UX646UU www]# cd cgi-bin
[root@HP-UX646UU cgi-bin]# ls
cg11.pl
[root@HP-UX646UU cgi-bin]# service httpd start
Starting httpd: [ OK ]
[root@HP-UX646UU cgi-bin]# chmod a+x cg11.pl
[root@HP-UX646UU cgi-bin]# cp cg11.pl hello.pl
[root@HP-UX646UU cgi-bin]# chmod a+x hello.pl

Kindly guide me.

Zulfi.
 
Old 10-02-2013, 07:13 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,516

Rep: Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501
Quote:
I am giving following command for execution:
Quote:
http://localhost/hello.pl
That's wrong, the correct URL is: http://localhost/cgi-bin/hello.pl
 
Old 10-03-2013, 03:30 AM   #3
zak100
Member
 
Registered: Jul 2009
Posts: 225

Original Poster
Rep: Reputation: 2
Hi,
Thanks for your help. I gave this command but still i am getting error:
Quote:
Forbidden
You dont have permission to access/cgi-bin/hello.pl on this server
It also pops up an ICON saying:
Quote:
SELINUX
AVC denial, click icon to view
For this purpose, I have clicked the "SELINUX Policy Generation Tool" and I have checked the "Web Application/Script (CGI)" option but then it asks:
Quote:
Enter name of application or user role to be confined
I dont know what information i have to supply in this text box.

Kindly solve this problem.

Zulfi.

Last edited by zak100; 10-03-2013 at 03:32 AM.
 
Old 10-03-2013, 03:55 AM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,600

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
Very likely the denial is caused by a mislabeling of the script.

Even though you didn't bother to include the reported error, very likely the script does not have the security label httpd_sys_script_exec_t (use "ls -Z filename" to see what the label is).
 
Old 10-03-2013, 04:57 AM   #5
zak100
Member
 
Registered: Jul 2009
Posts: 225

Original Poster
Rep: Reputation: 2
Hi,
Thanks for reply. I got following output of ls:
Quote:
[guest@HP-UX646UU ~]$ su
Password:
[root@HP-UX646UU guest]# cd /var/www/cgi-bin
[root@HP-UX646UU cgi-bin]# ls
cg11.pl hello.pl
[root@HP-UX646UU cgi-bin]# ls -Z hello.pl
-rwxr-xr-x root root unconfined_ubject_r:httpd_sys_script_exec_t:s0 hello.pl
[root@HP-UX646UU cgi-bin]#


If i click on the pop up window it disappears. It says click on icon, i dont know which icon its talking about.
Plz guide me why cgi script is not working.

Zulfi.

Last edited by zak100; 10-03-2013 at 05:03 AM.
 
Old 10-03-2013, 05:11 AM   #6
zak100
Member
 
Registered: Jul 2009
Posts: 225

Original Poster
Rep: Reputation: 2
Hi,
Thanks. I am able to execute. I checked the selinux trouble shooter and it says to execute a command which i executed and my cgi script is running.
Code:
[root@HP-UX646UU cgi-bin]# setsebool -P httpd_enable_cgi=1
[root@HP-UX646UU cgi-bin]#
Thanks for helping me.

Zulfi.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] problem in executing c program: glibc detected Ashotti Linux - Newbie 14 05-23-2012 05:23 AM
[SOLVED] Problem in executing lex program Arpitha Ms Programming 7 05-26-2011 07:39 AM
[SOLVED] problem regarding executing c program in ubuntu gerry_bertier Linux - Newbie 6 10-15-2010 08:44 AM
Problem Executing cgi Script from Plans Calendar jjp001 Linux - Server 3 10-24-2007 08:51 AM
Executing a program on server using CGi/PERl ?! avios Red Hat 1 12-29-2003 03:34 AM


All times are GMT -5. The time now is 09:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration