Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 04-21-2001, 02:38 PM   #1
Member (5 bit)
 
Join Date: Dec 2000
Posts: 25
I hope somome can help.

I am running PWS on a WIn2k PC and have installed PHP. I have configured
scripting in IIS to accept .pl. and .cgi commands. When I run the perl scripts I get it to work ok, but I also get a load of stuff that is supposed not to be there by the # command.
If you goto the following urls you will see what happens:-

http://scott-lewis.d2g.com/cgi-bin/test-perl.pl

or

http://scott-lewis.d2g.com/test/ (enter an e-mail address and you will see what happens)

Any ideas, advice or maybe web sites that can help.
--
Scott
http://www.toptravelsites.net
http://www.myeyes-youreyes.co.uk

slewis1972 is offline   Reply With Quote
Old 04-22-2001, 12:15 AM   #2
Member (13 bit)
 
Xayd's Avatar
 
Join Date: Jun 2000
Location: nowhere.com
Posts: 4,819
Send a message via AIM to Xayd
Moved to programming for ya, hopefully there'll be someone a bit more qualified to help ya that'll read it in here.

Xayd
Xayd is offline   Reply With Quote
Old 04-22-2001, 02:07 AM   #3
Member (12 bit)
 
Paul Victorey's Avatar
 
Join Date: Mar 1999
Location: MN or WI
Posts: 3,017
Can you post the source of the first PERL script (or both for that matter)?
__________________
Paul M. Victorey
------------------
I am not responsible for any problems that may arise as a result of following my advice. This includes, but is not limited to, computer failure, loss of data, nuclear war, famine, boils, no clean laundry, your daughter running off with a biker gang, or armageddon. Take my advice at your own risk.
Paul Victorey is offline   Reply With Quote
Old 04-22-2001, 03:17 AM   #4
Member (5 bit)
 
Join Date: Dec 2000
Posts: 25
Here is the tst-perl.pl script:-

#!/usr/bin/perl

##############################################
# test-perl.pl
# Matt Kynaston
# Say hi and print environment variables
#
# Lines that start with a hash mark (#), like this one, are
# comments, and are ignored by the Perl interpreter.
#
# The first line of this script tells the operating system
# where to look for the perl program. The Xitami browser
# ignores it, and looks at your computers PATH instead.
# Almost all Unix systems have it in /usr/bin/perl, but
# check with your host's help pages if nothing else works.



##############################################
# The following line is essential - it lets the server know
# that what follows is an html document

print "Content-type: text/html\n\n";


##############################################
# Now start printing the HTML document itself

print "Perl test ";
print "";
print "";
print "

Hello from Perl!

";


##############################################
# Now print a block of text - all the way to EOF marker

print << "EOF";

Congratulations! Perl is working
correctly on your system.


The following table lists environment
variables for this server. These can be useful
when it comes time to upload scripts onto your
host's server. Often you will need to know
information about paths so you can customise
your scripts.


Upload this script to your cgi-bin (make sure
you set the transfer mode to ASCII or TEXT!),
set the permissions on it to 755 then and view it
in your browser. The actual variable names will
vary from server to server, but have a look for one
called something like:



CGI_ROOT or SCRIPT_FILENAME

From it you should be able to work out the
absolute path to your cgi-bin.







EOF


##############################################
# Loop through the environment array, printing out each
# variable name and value on seperate rows

foreach $variable (sort keys %ENV) {
print "";
print "";
}


##############################################
# We're done!

print "

Environment Variable



Value


";
print "$variable
";
print "$ENV{$variable}
\n";
exit;
slewis1972 is offline   Reply With Quote
Old 04-22-2001, 03:19 AM   #5
Member (5 bit)
 
Join Date: Dec 2000
Posts: 25
Soory - the forum just seems to run the script. If you nead me to e-mail let me know.

Scott
slewis1972 is offline   Reply With Quote
Old 04-22-2001, 11:18 AM   #6
Member (12 bit)
 
Paul Victorey's Avatar
 
Join Date: Mar 1999
Location: MN or WI
Posts: 3,017
It looks like the script appeared fine?
I'd say offhand the fault lies with the interpreter and not the script.

However, one thing -- what kind of machine are you running the script on, and what kind of machine did you create it on?

Because, the newline character is different on different machines -- so if you made it on a PC and FTPd it onto a UNIX system using binary mode transfer, the interpreter might not see any newlines in the entire script.

Because of that, it would ignore the comments because comments must being with the # as the first character of the new line (I think, it's been a while).

Use ASCII mode to FTP your file in, that should work to convert the line breaks.

[Edited by Paul Victorey on 04-22-2001 at 12:21 PM]
Paul Victorey is offline   Reply With Quote
Old 04-22-2001, 12:55 PM   #7
Staff
Premium Member
 
mairving's Avatar
 
Join Date: Jul 1999
Location: Arlington, TN
Posts: 5,538
Generally whenever you get #comments from a perl script it is generally because the script is not executable. In Linux, you would do a chmod to fix this.

The first line of your script says /usr/bin/perl which would be the correct path in Linux. I really have never used perl for Windows but I would think that you need to change this line to whatever your path to perl on the II-s server is. It should be something like c:/path to perl.exe.

Also there should be two lines starting your script like this:
print "HTTP/1.0 200 OK\n";
print "Content-type: text/html\n\n";

I only saw one.
mairving is offline   Reply With Quote
Old 04-22-2001, 02:17 PM   #8
Member (12 bit)
 
Paul Victorey's Avatar
 
Join Date: Mar 1999
Location: MN or WI
Posts: 3,017
You don't truly need the HTTP status; the server will generate this for you if it is omitted (unless you use nph scripts).

I agree that you need to set the path -- in fact it definately appears that the script is not executing at all, but is simply being viewed.

Make sure you have (if it's a unix type system) execute permission for all (chmod 755 should work for you), and make sure the perl interpreter is at the correct location.
Paul Victorey is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 07:12 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2