LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Problem with executing first cgi program (https://www.linuxquestions.org/questions/linux-newbie-8/problem-with-executing-first-cgi-program-4175479307/)

zak100 10-02-2013 05:47 AM

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.

bathory 10-02-2013 06:13 AM

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

zak100 10-03-2013 02:30 AM

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.

jpollard 10-03-2013 02:55 AM

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).

zak100 10-03-2013 03:57 AM

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_u:object_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.

zak100 10-03-2013 04:11 AM

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.


All times are GMT -5. The time now is 12:12 PM.