View Full Version : Giving Perl a whirl
ronmtec
03-02-2002, 07:08 PM
Setting up UBB on a standard OSX client, but getting a '500' from Apache.
Tracked it to this:
My path to Perl has to have the '-T' at the end like this...
#!/usr/bin/perl -T
anyone know why?
Ron
ronmtec
03-02-2002, 10:26 PM
And to make it worse, taint mode for Perl seems to be permanently on for Apache under 10.1.3. UBB (Ultimate BBS) is perl based and won't run properly with taint mode on.
Anyone know how to turn off taint mode? (I've tried PerlTaintCheck Off
PerlWarn Off to no avail)
:confused:
Ron
pmccann
03-04-2002, 04:05 AM
Sad if it's true, but wholly unsurprising that ubb is unhappy to deal with taint mode being turned on. What makes you say that it "has to be on"?
That is, what happens if you just delete the "-T" from the first line of **every** script that ubb uses? (I'm guessing that maybe you entered "/usr/bin/perl -T" as the "path to perl" in a ubb configuration script?). Please correct me if I've got the wrong end of the stick.
Just to check that things run fine without taint mode, try saving the following four lines into a file (say "untainted.cgi") in your /Library/WebServer/CGI-Executables directory.
#!/usr/bin/perl
use strict;
use CGI ":standard";
print header,start_html("hollow world"),h1("Indeed..."),end_html;
Finally, make the thing executable:
% chmod 755 /Library/WebServer/CGI-Executables/untainted.cgi
and check whether it runs OK from your browser, via:
http://127.0.0.1/cgi-bin/untainted.cgi
Let us know if this doesn't work; we have the technology, we can rebuild it!
Cheers,
Paul
ronmtec
03-04-2002, 12:34 PM
Your script runs fine ... as long as I put a -T at the end of the '#!/usr/bin/perl' line.
If I take out the -T - I get a '500' error.
The error log says:
[Mon Mar 4 11:21:19 2002] [error] [client 127.0.0.1] Premature end of script headers: /Library/WebServer/CGI-Executables/untainted.cgi
all this is on the stock installation of apache that comes with 10.1.3
ronmtec
03-04-2002, 12:35 PM
Oh- and thanks for responding - I'm really stuck.
xchanyazy
03-04-2002, 02:19 PM
Which version of perl do you have installed? (perl --version) I have 5.6.0 and the script runs fine for me without the -T option. However, I don't remember if I installed that version myself, or if it is the one that came with osX.
mervTormel
03-04-2002, 03:10 PM
that would be the stock version, as i know i haen't installed no other...
% /usr/bin/perl --version
This is perl, v5.6.0 built for darwin
rudar
03-04-2002, 07:23 PM
Can you try running the untainted script above from the command line without going through apache?
perl /path/to/file/untainted.cgi
should spit out an html file in the terminal. At least this way we can figure out if it's Perl itself or apache that's unhappy. I'm starting to suspect the latter, and getting vague recollections of a line in httpd.conf configuring what apache allows to run. I think there's a decent section on taint modes, etc in ora's CGI programming with perl, which I do not have with me at the moment...
meancode
03-04-2002, 07:29 PM
hey all,
im glad (well ok not really) that im not the only one having this issue. i tryied UBB and ikonboard on OS X Server 10.1.3, and OS X Client 10.1.3, and i get the SAME error in my error log files that ronmtec describes. the "Premature end of script headers". i get that on both the Ikonboard and UBB files. i am looking into using the php UBB board right now. this is a pain.
ronmtec
03-04-2002, 08:44 PM
Good news - It's licked!
I found out that the line ending on the scripts were not unix type line endings, but the -T on the first line was somehow letting the script run ok. I opened each script in BBEDIT and saved again with unix line endings and I could run without the -T.
And note: I did unzip from the command line with unzip -a...
I found this out 'cause I decided to try -W on the line to see if it was just the presence of the switch that was helping to 'end' the line as far as the perl interpreter was concerned. It was. the -W made scripts run OK too. Using that, and the error 'Premature end of script ' - I finally figured out that it wasn't just the -T switch - it was the fact that perl didn't see the 'end' of the first line cause the line breaks were wrong (and they were 'dos' type lines endings - not mac).
So in the end it wasn't taint.
Thanks for the responses. If anyone wants details on making UBB run on the 10.1.3 apache I'll write it up cause it's running now!
By the way - this is a nice tight little community (this board). I appreciate the responses. (so much so that I contributed $ to macosxhints).
Ron
pmccann
03-05-2002, 12:00 AM
Hi again,
thanks for posting the way you resolved the difficulty: wish I'd been online late last night to suggest the line endings thing (I've lost track of the number of times I've interacted with people who eventually realised that they were having trouble with CGI's on OSX because of line ending problems. This realisation is often made more difficult by editors that translate "behind the scenes", particularly when they don't run BBEdit/Lite (for which there is no excuse!!). Persuading them to open a terminal window and use "less" is often difficult to impossible, as is getting them to use a perl-based conversion one-liner, so oftentimes I've ended up advising them to download Tex-Edit Plus or BBEdit Lite and do the conversions from there.)
What's *really* got me intrigued about your particular problem is the -T interaction (which was the focus of my head-scratching when your first posted). That's positively perverse! I'll have a quick play and see if I can come up with anything plausible.
Cheers, and great to hear that it's working now,
Paul
ronmtec
03-05-2002, 12:25 AM
Now what's a 'quick play' ?
I see you're from down under, are Mac's popular down there?
I'm a self employed Mac consultant in Birmingham, AL. USA.
I've always had a dream to do Mac consulting in your country. Any room left down there?
pmccann
03-05-2002, 01:00 AM
Hi again,
a "quick play" means just that (!); unfortunately I can't seem to reproduce the behaviour that you were seeing. With mac endings I just get ye olde 500 internal server error (premature end of script headings), with or without the taint flag. With DOS endings (CRLF) everything is hunky dory, which was something of a surprise! Though I guess apache does run fine on Win32. Oh yeah, that's with and without the taint flag. And obviously all's well with unix line endings. Hmm. Maybe it's a OSXS thang?
Re mac's in Australia: unfortunately things are similar to elsewhere. Circa 5%, maybe a little more, with the concentration in schools and universities greater than elsewhere. In my more optimistic moments I sense something of a slight turnaround in attitudes post OSX, but translating that into numbers is going to take a long, long, time. Indeed, my new job requires me to be running a PC, which is pretty sad; I'll start out on that platform, but hope to be able to stir in a new iMac further down the track, even if it means buying it myself!
So, to answer your question: the market is small but stable. A small number of firms soak up most of the support work on offer: educational institutions are being squeezed to death by the government, and are thus looking to cut back on external consultants, particularly in IT. So not much joy there.
On the up-side: cost of living is pretty cheap, as long as you don't plan on buying any computing books!! Use on-line vendors if you need to do that. (I'd mention Amazon, but that tends to get a few people's hackles up, so perhaps I'll just bracket this sentence. There.)
Cheers,
Paul
meancode
03-05-2002, 05:08 AM
pmccann, you seem to know a bit more about perl than i. why is it that if i use the UBB or ikonboard cgi scripts on my web site (my web host, Tera-Byte, uses Bobalt RaQ's) they work fine w/out me having to go into BBEdit and doing a save as to every single friggin script? my web server is unix, it runs apache, it also runs mod_perl.
pmccann
03-05-2002, 08:51 AM
Without a bit more info I couldn't tell you. ubb seems somewhat "unique" in coming as a .zip file. Almost everything else comes distributed as a tar.gz/tgz file, which decompresses to the right style line endings **as long as you don't let stuffit expander near it**. Well that's a bit harsh; I think there's an option in expander that says "don't touch my text files, thank you very much".
Yep (just quit stuffit), the "Cross Platform" preference panel should be set to "never". This should help a lot. Maybe that's what happened with your zip archive?
In any case, if you've got a directory full of files with "classic-mac" line-endings that you want converted to unix line endings you can simply open a terminal and enter:
% perl -pi -e 'tr/\015/\012/' *
(where % is the unix prompt) and wait a second or so. Of course you *won't* want to do this to image files (or any binary file), so you might need to restrict which files the script acts on. Something like
% perl -pi -e 'tr/\015/\012/' *.cgi
will work fine to convert all the .cgi files in the directory. You'll get a warning if there are any directories in there, but that's no problem: they're not touched.
If you want to do a whole directory hierarchy you can either investigate File::Find in perl, or use (for example):
% find . -name "*.cgi" -exec perl -pi -e 'tr/\015/\012/' {} \;
Of course you have to move *into* the directory concerned before executing the line above. Or you could just replace the "." in the above with the name of the directory that you want changed. (Groovy: now I know how to do the hierarchical thang myself!).
Hope this helps somewhat,
Paul
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.