Powered by glolg
Display Preferences Most Recent Entries Chatterbox Blog Links Site Statistics Category Tags About Me, Myself and Gilbert XML RSS Feed
Monday, Jan 21, 2008 - 01:15 SGT
Posted By: Gilbert

- -
Invisible Character

Having finally gotten it into my mind to try out Perl on the SOC Zone so kindly set up for me, I got Apache and PHP up and running easily enough (can't say the same for the non-Computing students in the module, not least because they don't have access to the MySOC help pages). Perl wasn't as simple, though, and my heart sank a little when the basic httpd.conf changes didn't work out - the dreaded 500 Internal Server Error greeted me.

I will be first to admit that I'm no Linux whiz, and indeed even the command to directly create a file from the command line (cat, don't ask why) eluded me at first; The last time I used any flavour of Unix with regularity was a few semesters back for CS2106 Operating Systems. Finding the temerity (terminity?) of PuTTY not to my liking, I found EngInSite DataFreeware's GUI frontend much friendlier. It didn't have a convenient way to upload files, however, so with some combination of the two I plodded on.

Under the assumption that the mod_perl Apache interpreter was a must for running Perl on Apache (no thanks to all my Googles for Apache Perl and the like returning some reference to it), I browsed through the installation procedures (which were written for a clean install of Apache), and decided to seek other avenues. It was about this time that I hit upon the bright idea to inspect the error logs, which I had downloaded once before but turned out empty on my local drive (which I discovered was simply because I didn't have sufficient rights). With vim but not much vigour, I discovered that at least the server had received the requests, but had rejected each and every one of them with "Premature end of script headers, file does not exist, nyeah nyeah nyeah".

Checked the line out, and rechecked my Hello World cgi script. Shebangs usr/bin/perl... Hmm... D'oh! It was supposed to be "#!/usr/bin/perl" not "#!usr/bin/perl". One missing forward slash. Refreshed Apache (didn't know if it was necessary, was for my Java stuff last time), and nothing.

Read more about mod_perl, downloaded the tar file. Then realised that there was some warning about non-UNIX line endings when developing on Windows platforms. Supposedly dos2unix would fix it, so I dutifully did "dos2unix test.cgi". Didn't work. Tore some more hair.

Stared at the mod_perl install options some more. It didn't really have to end up like this, right? Fiddled about with the permissions and config file, then finally hit upon the bright idea of typing in the Hello World script directly, with "cat > test2.cgi". Still zero. Hmm. Oh yes, the permissions for the new file are still default. Changed them, then bingo! Perl lives!

So why didn't the dos2unix treatment work? Two reasons: One, I had used it incorrectly. If I had read the man page first, I would have realised that the correct invocation is "dos2unix (inputfile) (outputfile)", and instead I assumed that it would just directly overwrite the original. Two, I think it resets the permissions silently even when the input and output files are the same. Well, that's the hardest over. I don't think I will be tinkering with mod_perl for awhile, even if it does promise to run CGI calls 2000% faster. There's a prize for crashing the server anyway :P


And the bane of my existence? The invisible carriage return. Two miserable bytes. And the shell rolls over and dies on me. Why can't all the OSes just be friends?



comments (2) - email - share - print - direct link
trackbacks (1) - trackback url


Next: Schedule of Doom


Related Posts:
I Am So Screwed
Clearly Improved
The Wagers Of Sin
Holidays, Week One
Ho Ho Ho

Back to top




2 comments


LaW said...

I've simply no idea what all these mean..


January 21, 2008 - 08:58 SGT     

gilbert said...

Some secrets are not meant for the eyes of non-Computing majors, lest they peel away at their sanity...


January 22, 2008 - 15:46 SGT     


1 trackback


Trackback by actos claims

actos claims - [bert's blog]


July 28, 2014 - 11:09 SGT     


Copyright © 2006-2025 GLYS. All Rights Reserved.