Run a Perl program from an HTML page without user intervention

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • owlice
    New Member
    • Aug 2007
    • 13

    #16
    Originally posted by KevinADC
    if this works in the image tag: CGI/tipweek.pl it should work in the SSI tag unless SSI is disabled or the "virtual" tag is disabled. But even though your perl script only updates files it still has to return an appropriate MIME header back to the calling page otherwise it will retun a 500 internal server error. If you are using the image tag to call the script you will not see the error as the image tag expects an image file with an image header, but it will return a broken image symbol or as we used to call them a pizza box, the little square with the "x" in it. I would check the error log and see if it is not filling up with errors/warnings related to calling the perl script.
    Amazingly enough, I don't get a pizza box! I thought I would, but no... the result was simply some extra vertical space, hence my moving the IMG tag to the end of the HTML document, where a little extra vertical space doesn't matter.

    I find this positively weird.

    SSI is definitely enabled; my test page had another #include in it, and that has always worked. It could be that the "virtual" attribute is indeed disabled on the server, and I'll ask the web guys tomorrow if that's the case; I would imagine that one of them should be able to tell me. (For my test script, #include file="CGI/tipweek.pl" pulled the Perl code itself into the HTML page; #include virtual="CGI/tipweek.pl" didn't work. Yeah, it's gotta be turned off; maybe I can convince someone to turn it on.)

    I don't know that I can check the error log; I suspect not, but if you can give me a clue as to how one checks one, I'll give it a shot.

    Attach your perl script to a post and if I get a chance I will look at it.
    Should be good amusement! (I didn't use "strict," I didn't declare variables, and I know I'll have to do a version 2.0, as I recognize the program could potentially get into an endless loop, but so long as it has what it needs in the data source file, it does what it's supposed to do, so I'm calling it done! :-D )

    I'll attach it, but it might take me until Tuesday, as I'm up against a deadline to get this whole rewrite (of my whole site) into production. I'm SO far behind because of my "trivial" little tip of the week app and its numerous opportunities for learning, I'm scrambling for the next few days.

    Overall, I've concluded that I probably should have done what I did in Javascript, but I know even less Javascript than Perl. (Actually, ColdFusion might have been the best choice, that and a database, but CF and databases get more oversight than Perl and text files, so...)

    Comment

    • owlice
      New Member
      • Aug 2007
      • 13

      #17
      So my next question is: should I let the goat off the hook now, or wait until everything's in production? :-D

      Comment

      • KevinADC
        Recognized Expert Specialist
        • Jan 2007
        • 4092

        #18
        Your browser might be set to not show the broken image place holder. That would explain the no pizza box affect.

        The error log can be checked a number of ways, via a control panel if there is one, via FTP if you can get into the logs folder, via telnet if you can log in that way. Ask your tech support people how.

        Comment

        • owlice
          New Member
          • Aug 2007
          • 13

          #19
          Oh, I definitely get pizza boxes, and I'm glad for that, as it's a good check for me after I've updated things, am checking them in production, and find I've forgotten to move a new graphics file over.

          Thanks for the info on the error log! Will talk to the gurus to see whether I have access.

          Comment

          • owlice
            New Member
            • Aug 2007
            • 13

            #20
            Now the solution is to have the network guy schedule my Perl script to run every Sunday, rather than invoking it from a web page. That is a better way to handle it, and if something happens that prevents the script from running, I can always run it by putting the URL into my browser. We never did figure out why I cannot invoke this script through a more normal method (rather than the IMG tag).

            The Perl code is attached; I had to add the .txt extension to upload it. I know there's the possibility of an endless loop; I'll fix that someday! :-) I also need to add a bit of documentation to the code.

            The layout of the source file (tipsource.txt) and two examples are given below.

            tipsource.txt structure: wknum|Year|TipT itle|TipDesc|Ti pURL|TipTech
            36|07|Voice Mail Tips: Shortcuts for reviewing voice mail messages|When you are listening to your messages, do you want to fast forward or delete without listening to the full message? You can!|0736.htm|P hone
            37|07|Reorderin g columns in Excel using horizontal sort|Have you ever needed to rearrange the columns in a spreadsheet? Did you Copy and paste the entire column in a new spreadsheet in the order you wanted them? There is an easier way to sort your columns.|0737.h tm|Excel
            Attached Files
            Last edited by owlice; Sep 13 '07, 04:58 PM. Reason: added attachment; added example of source file layout

            Comment

            • owlice
              New Member
              • Aug 2007
              • 13

              #21
              Originally posted by owlice
              I also need to add a bit of documentation to the code.
              And fix some of what's there, and take out a few lines that shouldn't be there, and...

              (But the good news is that the goat is now free!)

              Comment

              • KevinADC
                Recognized Expert Specialist
                • Jan 2007
                • 4092

                #22
                After a quick glance at the code it looks well commented/documented. But it does look like it could use some improvements. If I get a chance I will give it a closer look and make some recommendations if any are warranted.

                Comment

                • owlice
                  New Member
                  • Aug 2007
                  • 13

                  #23
                  Kevin, I posted it to amuse you. ("Kids, don't code like this!" :-D) I'm sure it could stand improvements. I learned only what was absolutely necessary to write it, and no doubt there are things that I'd have coded better/differently/etc. if I knew Perl. I'll probably make just minor changes to it after this, however, and only if I really have to. (I'm not a programmer, nor do I play one on TV.)

                  I appreciate all your help; you've been a peach! Thanks!

                  Comment

                  Working...