Monday, September 24, 2012

PHP Is The Way To Go; Not CGI ksh

I still haven't a clue why I can't get CGI scripts written in ksh to work on HostRocket's web hosting server, but I do have a PHP script written pretty painlessly.  I have actually reached the point where the last part of the problem remains to be solved--which is a puzzle akin to an IQ test.  No surprise there.

If I don't get an interview out of this, I will be very upset.

UPDATE: I am most of the way solved on this, but it would sure help if there was a way to run a debugger for PHP on Unix.  Even being able to execute my PHP script from the shell, instead this indirect method by having someone else send an HTTP GET request would help.  My guess is that $_GET["q"] and $_GET["d"] in PHP are retrieving variables that can be set from the shell, so that I can debug this in a more natural way.  Any ideas?

I figured out the puzzle, by the way.  It would make a fine Mensa entrance test, and not one of the easy ones, either.  Now it's just a matter of debugging the PHP script.

UPDATE 2: Silly me.  I just need to change the two lines at the beginning that retrieve the GET variables to retrieve environment variables instead, and then I can execute it in the shell.

UPDATE 3: The puzzle part of the script was a bit more complicated than I first thought, but I did finally finish it, and was able to submit my resume.  If this isn't actually a front organization for the NSA, I can't imagine a persuasive argument for such a demanding test.  I learned a bit about HTTP GET requests and how they work, learned to program in PHP (which is always good) and found an easy way to debug PHP server scripts from the command line in Unix.

2 comments:

  1. I've messed with Apache and static HTTP (or HTTP updated by script tools like RAWDOG, the RSS Aggregator Without Delusions of Grandeur). I also put some PHP into one folder on that server.

    But never CGI. And the PHP assembled a dynamic page out of a pool of files in the local folder, and didn't parse query strings that were handed in along with GET.

    I figure whichever-company-it-is has some in-house team that has methods and knowledge for building CGI scripts. You're probably duplicating knowledge that the team already has.

    (Unless it's knowledge the team used to have in an undocumented manner, and no longer has because somebody left.)

    But somebody told the hiring manager about CGI scripts, and he decided to ask for an example. Or the hiring manager used to do CGI all the time, and figures it's easy to demo/learn.

    Sounds challenging. I wonder if it's the kind of challenge I want to take up.

    ReplyDelete
  2. FWIW, I've been using NetBeans for an IDE because it allows me to debug PHP code.

    There just isn't any substitute for being able to single-step through code and watch variables change value.

    ReplyDelete