LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Closed Thread
 
Search this Thread
Old 09-17-2003, 07:51 PM   #1
WorldBuilder
Member
 
Registered: Mar 2003
Location: Massachusetts, USA
Distribution: RH 8, Solaris, Windoze eXPunged
Posts: 520

Rep: Reputation: 30
perl problem? apache problem? cgi problem?


Hi all, this is actually kind of a continuation of a post I made at http://www.linuxquestions.org/questi...threadid=93823

I got a lot of great help there, and there is only one thing that is still not working. Here's the story.

I run apache 2.0.x on a RH 8 server. I THINK I got cgi-bin working properly (but would like some validation!). Now, in my cgi-bin directory, there are 3 files: "test-cgi" and "printenv" (both of which are there from the apache installation) as well as a cgi script I created for an introductory perl class called "hello.cgi".

I noticed some things...

First, here is the code for all 3 files right now:


test-cgi:
#!/bin/sh

# disable filename globbing
set -f

echo Content-type: text/plain
echo

echo CGI/1.0 test script report:
echo

echo argc is $#. argv is "$*".
echo

echo SERVER_SOFTWARE = $SERVER_SOFTWARE
echo SERVER_NAME = $SERVER_NAME
echo GATEWAY_INTERFACE = $GATEWAY_INTERFACE
echo SERVER_PROTOCOL = $SERVER_PROTOCOL
echo SERVER_PORT = $SERVER_PORT
echo REQUEST_METHOD = $REQUEST_METHOD
echo HTTP_ACCEPT = "$HTTP_ACCEPT"
echo PATH_INFO = "$PATH_INFO"
echo PATH_TRANSLATED = "$PATH_TRANSLATED"
echo SCRIPT_NAME = "$SCRIPT_NAME"
echo QUERY_STRING = "$QUERY_STRING"
echo REMOTE_HOST = $REMOTE_HOST
echo REMOTE_ADDR = $REMOTE_ADDR
echo REMOTE_USER = $REMOTE_USER
echo AUTH_TYPE = $AUTH_TYPE
echo CONTENT_TYPE = $CONTENT_TYPE
echo CONTENT_LENGTH = $CONTENT_LENGTH

hello.cgi:
#!/usr/bin/perl

use CGI ':standard';
use CGI::Carp 'fatalsToBrowser';

$message = "Hello World!";

print header,
start_html($message),
h1($message),
h2($message),
h3($message),
h4($message),
h5($message),
h6($message),
hr,
end_html;

printenv:
#!/usr/bin/perl
##
## printenv -- demo CGI program which just prints its environment
##

print "Content-type: text/plain\n\n";
foreach $var (sort(keys(%ENV))) {
$val = $ENV{$var};
$val =~ s|\n|\\n|g;
$val =~ s|"|\\"|g;
print "${var}=\"${val}\"\n";
}

From the get-go, "test-cgi" worked when I viewed it in a web browser, but "printenv" and hello.cgi did not. I finally got "printenv" to work. I did so by changing the path to the PERL interpreter. You'll notice that printenv and hello.cgi are PERL scripts, but test-cgi is not. Well, the path to my PERL interpreter is /usr/bin/perl. printenv USED to be /usr/local/bin/perl. As soon as I changed that, it started working. Now, the output in a browser for that is:

DOCUMENT_ROOT="/home/www"
GATEWAY_INTERFACE="CGI/1.1"
HTTP_ACCEPT="image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*"
HTTP_ACCEPT_ENCODING="gzip, deflate"
HTTP_ACCEPT_LANGUAGE="en-us"
HTTP_CONNECTION="Keep-Alive"
HTTP_HOST="www.bartlett-family.net"
HTTP_USER_AGENT="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"
PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin"
QUERY_STRING=""
REMOTE_ADDR="192.168.5.16"
REMOTE_PORT="1979"
REQUEST_METHOD="GET"
REQUEST_URI="/cgi-bin/printenv"
SCRIPT_FILENAME="/usr/local/apache2/cgi-bin/printenv"
SCRIPT_NAME="/cgi-bin/printenv"
SERVER_ADDR="24.128.150.74"
SERVER_ADMIN="postmaster@bartlett-family.net"
SERVER_NAME="www.bartlett-family.net"
SERVER_PORT="80"
SERVER_PROTOCOL="HTTP/1.1"
SERVER_SIGNATURE="<address>Apache/2.0.46 (Unix) PHP/4.3.2 Server at www.bartlett-family.net Port 80</address>\n"
SERVER_SOFTWARE="Apache/2.0.46 (Unix) PHP/4.3.2"

COOL! Ok, so I can now assume that cgi and perl are working, right? Yes, No, Maybe? But why is my hello.cgi script not working? Let me know if I am missing something! Thanks!

Chris

PS. The only other thing I can think of is this: While in the cgi-bin directory:

# ls -l
total 12
-rwxr-xr-x 1 chris chris 264 Sep 17 15:07 hello.cgi
-rwxr-xr-x 1 11056 303 268 Sep 17 16:09 printenv
-rwxr-xr-x 1 11056 303 757 Aug 24 1999 test-cgi

The only other thing that strikes me as odd is that the files other than hello.cgi are owned by whatever the hell the 303 and 11056 numbers are, while hello.cgi is owned by me... Does that matter for some reason?
 
Old 09-17-2003, 08:45 PM   #2
trickykid
Guru
 
Registered: Jan 2001
Posts: 24,133

Rep: Reputation: 199Reputation: 199
Lets not start the existing discussion in a new thread, this is against the rules. Lets continue in the existing one please.
I have reported this thread and it should be closed.

Regards.

http://www.linuxquestions.org/rules.php
 
  


Closed Thread


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
HELP:perl CGI problem supermyself Programming 2 06-12-2005 09:34 AM
CGI -PERL Problem!!! lewkh Fedora 3 05-10-2005 01:19 AM
CGI/Perl problem with SuExec kalbaz Linux - General 2 10-18-2003 07:25 PM
apache cgi problem nyroc Linux - Software 2 11-30-2002 12:09 AM
Problem with perl and cgi files JSP Linux - General 1 03-22-2002 09:01 AM


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

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration