Unable to run cgi script

2002-11-11 Thread Kelvin McWha
I am trying to set my system up as a Webserver
for testing purposes
System is
SuSe 8.1 stand-a-lone
Apache 1.3

Have got Apache running OK and tested it in standalone mode using
http://localhost
which shows the appropriate test page

I have configured httpd.config to point to my directories as follows
ScriptAlias /cgi-bin/  /home/kelvin/cgi-bin/
Directory /home/kelvin/cgi-bin
  Options +ExecCGI
 AddHandler cgi-script cgi pl 
 /Directory

I am now trying to run simple html  perl scripts as shown below
htmlhead
titleMy test page/title
/headbody
form method=post action=/home/kelvin/cgi-bin/myscript.cgi
PRE
First Name  INPUT TYPE=text NAME=fname MAXLENGTH=15
SIZE=15
Last Name   INPUT TYPE=text NAME=lname MAXLENGTH=20
SIZE=20
E-Mail Addr INPUT TYPE=text NAME=email MAXLENGTH=35
SIZE=35
INPUT TYPE=submit VALUE=Send Mail!
INPUT TYPE=reset VALUE=Clear-Form
/PRE
/form/body/html

#!/usr/bin/perl
use CGI;
read(STDIN,$temp,$ENV{'CONTENT_LENGTH'});
@pairs=split(//,$temp);
foreach $item(@pairs)
{
($key,$content)=split(/=/,$item,2);
$content=~tr/+/ /;
$content=~s/%(..)/pack(c,hex($1))/ge;
$fields{$key}=$content;
}
print Content-type: text/html\n\n;
print HTML\n;
print BODY BGCOLOR=#FF\n;
print CENTRE\n;
print Thank YouBR\n;
print $fields{fname} $fields{lname}BR;
print I will writeBR\n;
print you atBR\n;
print $fields{email}BR\n;
print /CENTRE\n;
print /BODY/HTML;

What happens when I run the html code and click send, is that instead of
running the perl script it attempts to open it. I have tried a number of
scripts and they all do the same. I am sure it is something simple but
it's got me beat. 

Thanking you in anticipation
Kelvin



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Unable to run cgi script

2002-11-11 Thread Kelvin McWha
mmm. to be honest Robert I picked this script up on the web and I have
used it as an example to show that my system will not run cgi scripts,
it also does not show any errors but opens them for editing instead. I
don't think I'm anywhere near looking at cgi.pm yet I am simply trying
to teach myself the basics so I need to get up and running first.

Thanks

Kelvin

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:ROBERT_MCCAMMON;denso-
 diam.com]
 Sent: 11 November 2002 13:31
 To: Kelvin McWha
 Subject: Re: Unable to run cgi script
 
 
 
 If I may ask, why are you using STDIN when using CGI.  On the CGI.PM
 help page
 it shows the the use of param().  This is much simpler to receive your
 enviromental variables.
 
 This will be done completely inside the script.  It save considerable
 typing.
 Below shows the header.
 
 #!/usr/bin/perl
 use CGI qv(standard);
 use strict;
 
 
 
 I am trying to set my system up as a Webserver
 for testing purposes
 System is
 SuSe 8.1 stand-a-lone
 Apache 1.3
 
 Have got Apache running OK and tested it in standalone mode using
 http://localhost
 which shows the appropriate test page
 
 I have configured httpd.config to point to my directories as follows
 ScriptAlias /cgi-bin/??home/kelvin/cgi-bin/
 Directory /home/kelvin/cgi-bin
   Options +ExecCGI
  AddHandler cgi-script cgi pl
  /Directory
 
 I am now trying to run simple html  perl scripts as shown below
 htmlhead
 titleMy test page/title
 /headbody
 form method=post action=/home/kelvin/cgi-bin/myscript.cgi
 PRE
  First Name INPUT TYPE=text NAME=fname MAXLENGTH=15
 SIZE=15
  Last Name  INPUT TYPE=text NAME=lname MAXLENGTH=20
 SIZE=20
  E-Mail AddrINPUT TYPE=text NAME=email MAXLENGTH=35
 SIZE=35
INPUT TYPE=submit VALUE=Send Mail!
INPUT TYPE=reset VALUE=Clear-Form
 /PRE
 /form/body/html
 
 #!/usr/bin/perl
 use CGI;
 read(STDIN,$temp,$ENV{'CONTENT_LENGTH'});
 @pairs=split(//,$temp);
 foreach $item(@pairs)
 {
 ($key,$content)=split(/=/,$item,2);
 $content=~tr/+/ /;
 $content=~s/%(..)/pack(c,hex($1))/ge;
 $fields{$key}=$content;
 }
 print Content-type: text/html\n\n;
 print HTML\n;
 print BODY BGCOLOR=#FF\n;
 print CENTRE\n;
 print Thank YouBR\n;
 print $fields{fname} $fields{lname}BR;
 print I will writeBR\n;
 print you atBR\n;
 print $fields{email}BR\n;
 print /CENTRE\n;
 print /BODY/HTML;
 
 What happens when I run the html code and click send, is that instead
of
 running the perl script it attempts to open it. I have tried a number
of
 scripts and they all do the same. I am sure it is something simple but
 it's got me beat.
 
 Thanking you in anticipation
 Kelvin
 




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Unable to run cgi script

2002-11-11 Thread David T-G
Kelvin --

...and then Kelvin McWha said...
% 
...
% form method=post action=/home/kelvin/cgi-bin/myscript.cgi

I *think* you have to qualify this, as

  action=http://localhost/home/kelvin/cgi-bin/myscript.cgi;

Certainly worth a try...


HTH  HAND

:-D
-- 
David T-G  * There is too much animal courage in 
(play) [EMAIL PROTECTED] * society and not sufficient moral courage.
(work) [EMAIL PROTECTED]  -- Mary Baker Eddy, Science and Health
http://www.justpickone.org/davidtg/Shpx gur Pbzzhavpngvbaf Qrprapl Npg!




msg06869/pgp0.pgp
Description: PGP signature


Convert IP address

2002-11-11 Thread Mike(mickako)Blezien
Hello,

was wondering if there is a module or someone may know of a quick means of 
convering a IP address to a host/domain address.

this is a snip of code we use to use, but I don't think it works very well any more:

# Covert Host IP Address to domain name IE: [somedomain.com]
 $ip = remote_addr();
 $n = `nslookup -sil $ip | grep Name`; chomp($n);
 $dns_host=substr($n, rindex($n,  )+1);
 $period1=rindex($dns_host,'.');
 $period2=rindex($dns_host,'.',$period1-1);
 $domain_host = substr($dns_host,$period2+1);
 # Now split secondary domain to top level domain
  ($sec_domain, $top_domain) = split(/\./, $domain_host);

then we could obtain the secondary and top domain names... any other suggestions 
would be much appreciated. :)

TIA,
--
MikemickaloBlezien
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Thunder Rain Internet Publishing
Providing Internet Solutions that work!
http://www.thunder-rain.com
Tel:  1(985)902-8484
MSN: [EMAIL PROTECTED]
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Convert IP address

2002-11-11 Thread WilliamGunther
In a message dated 11/11/2002 9:16:10 AM Eastern Standard Time, 
[EMAIL PROTECTED] writes:


 was wondering if there is a module or someone may know of a quick means of 
 convering a IP address to a host/domain address.

$ip = $ENV{'REMOTE_ADDR'};
@digits = split (/\./, $ip);
$address = pack (C4, @digits);
$host = gethostbyaddr ($address, 2);



RE: Unable to run cgi script

2002-11-11 Thread Kelvin McWha
Thanks David that seems to have taken me a step further. Running the
html script now comes up with the error Not Found
The requested URL /home/Kelvin/cgi-bin/myscript.cgi was not found on
this server

The browser is pointing to
http://localhost/home/kelvin/cgi-bin/myscript.cgi
I have tried it with several other scripts each time with the same
result

What next please?

Kelvin

 -Original Message-
 From: David T-G [mailto:davidtg-perl-beginners;justpickone.org]
 Sent: 11 November 2002 13:58
 To: perl beginners cgi
 Cc: Kelvin McWha
 Subject: Re: Unable to run cgi script
 
 Kelvin --
 
 ...and then Kelvin McWha said...
 %
 ...
 % form method=post action=/home/kelvin/cgi-bin/myscript.cgi
 
 I *think* you have to qualify this, as
 
   action=http://localhost/home/kelvin/cgi-bin/myscript.cgi;
 
 Certainly worth a try...
 
 
 HTH  HAND
 
 :-D
 --
 David T-G  * There is too much animal courage in
 (play) [EMAIL PROTECTED] * society and not sufficient moral
courage.
 (work) [EMAIL PROTECTED]  -- Mary Baker Eddy, Science and
 Health
 http://www.justpickone.org/davidtg/Shpx gur Pbzzhavpngvbaf Qrprapl
 Npg!




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Unable to run cgi script

2002-11-11 Thread Scot Robnett
I don't think that's it; with the ScriptAlias set it should call the script
through a relative or full path as easily as it does via that full HTTP
call. I'm curious what the document root is...if it is /home/kelvin, then
technically you *should* just be able to write it as form
action=/cgi-bin/myscript.cgi. Or, if you want to try the HTTP call, form
action=http://localhost/cgi-bin/myscript.cgi;.

It sounds to me like .cgi or .pl may already have file associations with an
external application (since the scripts are opening in your editor), and for
some reason those are overriding your AddHandler directive in Apache. Did
you try troubleshooting it by using an either/or approach? By this I mean
simply adding a handler for either .cgi or .pl but not both, and trying it
that way.

What are the results you get when you run the script via the command line or
run a perl -c on it?

Another quick question: I noticed that you called the configuration file
httpd.config. Since its actual name is httpd.conf, I wonder if it's as
simple as renaming your configuration file? If you already have it named
httpd.conf, then never mind this question. :)

-
Scot Robnett
inSite Internet Solutions
Square West Center
454 West Jackson Street
Woodstock, IL 60098
(815)206-2907 office
(815)342-6480 mobile
[EMAIL PROTECTED]
http://www.insiteful.tv


-Original Message-
From: David T-G [mailto:davidtg-perl-beginners;justpickone.org]
Sent: Monday, November 11, 2002 7:58 AM
To: perl beginners cgi
Cc: Kelvin McWha
Subject: Re: Unable to run cgi script


Kelvin --

and then Kelvin McWha said...
%

% form method=post action=/home/kelvin/cgi-bin/myscript.cgi

I *think* you have to qualify this, as

  action=http://localhost/home/kelvin/cgi-bin/myscript.cgi;

Certainly worth a try...


HTH  HAND

:-D
--
David T-G  * There is too much animal courage in
(play) [EMAIL PROTECTED] * society and not sufficient moral courage.
(work) [EMAIL PROTECTED]  -- Mary Baker Eddy, Science and Health
http://www.justpickone.org/davidtg/Shpx gur Pbzzhavpngvbaf Qrprapl Npg!



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Unable to run cgi script

2002-11-11 Thread Kelvin McWha
So I have tried the method below ie

form action=/cgi-bin/myscript.cgi

and the server was unable to find the file? 
I have tried commenting out the other alias which was pointing somewhere
else for the cgi-bin
I have removed the file associations with each pl/cgi file this then
brings up the open with dialog box

So my guess is somehow Apache isn't opening the cgi files. Apache is
running I proved it with the localhost page

And another thing running the script by the command line just produces
the script, by that I mean, where I would have thought it would have run
the html bit it doesn't. It prints all the tags as well. Or am I
misunderstanding what should happen?

Any other suggestions please

Kelvin

 -Original Message-
 From: Scot Robnett [mailto:scot;insiteful.tv]
 Sent: 11 November 2002 14:44
 To: David T-G; perl beginners cgi
 Cc: Kelvin McWha
 Subject: RE: Unable to run cgi script
 
 I don't think that's it; with the ScriptAlias set it should call the
 script
 through a relative or full path as easily as it does via that full
HTTP
 call. I'm curious what the document root is...if it is /home/kelvin,
then
 technically you *should* just be able to write it as form
 action=/cgi-bin/myscript.cgi. Or, if you want to try the HTTP call,
 form
 action=http://localhost/cgi-bin/myscript.cgi;.
 
 It sounds to me like .cgi or .pl may already have file associations
with
 an
 external application (since the scripts are opening in your editor),
and
 for
 some reason those are overriding your AddHandler directive in Apache.
Did
 you try troubleshooting it by using an either/or approach? By this I
mean
 simply adding a handler for either .cgi or .pl but not both, and
trying it
 that way.
 
 What are the results you get when you run the script via the command
line
 or
 run a perl -c on it?
 
 Another quick question: I noticed that you called the configuration
file
 httpd.config. Since its actual name is httpd.conf, I wonder if it's as
 simple as renaming your configuration file? If you already have it
named
 httpd.conf, then never mind this question. :)
 
 -
 Scot Robnett
 inSite Internet Solutions
 Square West Center
 454 West Jackson Street
 Woodstock, IL 60098
 (815)206-2907 office
 (815)342-6480 mobile
 [EMAIL PROTECTED]
 http://www.insiteful.tv
 
 
 -Original Message-
 From: David T-G [mailto:davidtg-perl-beginners;justpickone.org]
 Sent: Monday, November 11, 2002 7:58 AM
 To: perl beginners cgi
 Cc: Kelvin McWha
 Subject: Re: Unable to run cgi script
 
 
 Kelvin --
 
 and then Kelvin McWha said...
 %
 
 % form method=post action=/home/kelvin/cgi-bin/myscript.cgi
 
 I *think* you have to qualify this, as
 
   action=http://localhost/home/kelvin/cgi-bin/myscript.cgi;
 
 Certainly worth a try...
 
 
 HTH  HAND
 
 :-D
 --
 David T-G  * There is too much animal courage in
 (play) [EMAIL PROTECTED] * society and not sufficient moral
courage.
 (work) [EMAIL PROTECTED]  -- Mary Baker Eddy, Science and
 Health
 http://www.justpickone.org/davidtg/Shpx gur Pbzzhavpngvbaf Qrprapl
 Npg!
 
 
 
 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]