473,698 Members | 2,972 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Run a Perl program from an HTML page without user intervention

13 New Member
Greetings!

I thought I'd add a little something to a web site, a "tip of the week," and wanted it automated so that if I get hit by a truck (or, more likely, am forgetful), the tip is updated automatically.

I learned enough Perl (read: just enough) to code a script that does what I want it to do. Now the question is: how to get it to run automatically.

I would like the program to be invoked when someone, anyone, hits my homepage. I know little about our environment -- I'm not a developer -- but know that I'm on a Windows box and that we're running IIS. Server-side includes work. Perl for use with forms works. Beyond that, I must offer my apologies for my cluelessness.

I've tried to use the #exec command on my HTML page to invoke the Perl script. Doesn't work. Here's the HTML to my test page:

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
  2.  
  3. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml">
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  7.  
  8. <title>testing perl script from HTML page</title>
  9. </head>
  10.  
  11. <body>  
  12. <!--#exec "d:/webdocs/www/irm/training/CGI/tipweek.pl" -->
  13. <p>This page is to test to see whether I can run a Perl script from an HTML page.</p>
  14. <p>&nbsp;</p>
  15. <br>
  16. </p><p>Other stuff on the page, including a server-side include below this line.</p>
  17. <p>
  18.   <!--#include file="Tips/currenttip.txt" -->
  19. <br>
  20. </p>
  21. </body>
  22. </html>
  23.  
I do not get an error message, but the files that are supposed to be updated are not updated, so something isn't happening that should be happening.

If I enter the URL for the Perl script into my browser, the script runs; the files are updated.

I don't want the Perl script to create my homepage, as I'm not the only one who needs to be able to edit the page.

Is there some relatively painless way to invoke a Perl script (which doesn't use user input and doesn't need to return anything to the page) from an HTML page?

TIA!
Aug 30 '07
22 6026
owlice
13 New Member
Heh! Jeff, I've probably tried that; I've tried many many things.

Kevin, not that it matters much (well, I suppose it does to some, but not to anyone here!), that'd be her Perl script. :-)

I'd post the script (or rather, attach it, because it's a little long) if I thought that would help, but I know the script works, so I don't think that's the problem. I think you're right in thinking I just need the right tag or SOMEthing. The error is in the HTML page, not in the script.

I'm sure the script would amuse the real Perl programmers here, however, so there might be a comic value in posting it!
Sep 4 '07 #11
owlice
13 New Member
Okay, I found something that works. I don't believe it, but it does. It's
Expand|Select|Wrap|Line Numbers
  1. <img src="CGI/tipweek.pl" border=0 height=0 width=0>
I found that here a while ago: http://www.webxpertz.n et/forums/archive/index.php/t-710.html

It hadn't worked for me before, but perhaps it was because I hadn't tested it the same way I'm testing now (read: not quite as well).

SO weird!

Thank you for your help, gentlemen; I really appreciate it, and if I find the right way to do this, I'll post that as well.
Sep 4 '07 #12
KevinADC
4,059 Recognized Expert Specialist
That can work but the perl script should be returning an image, not text. This is the SSI tag you want to use:

<!--#include virtual="../CGI/tipweek.pl" -->

you just need to get the "../CGI/tipweek.pl" part correct for it to work.
Sep 4 '07 #13
owlice
13 New Member
Thanks, Kevin!

The Perl program doesn't return anything to the web page, nor is it supposed to; it simply checks info and updates files if they need updating.

Putting the IMG tag at the bottom of the HTML code works well; put somewhere else, I get a little empty space on the page. The first time the browser hits the page, the #include file=Tips/currenttip.txt still displays with the previous week's info (as it should, as the Perl script hasn't updated it yet), but the second hit/refresh shows the update, and that's fine.

I tried every variation of the path (logical to riduculous, this-can't-possibly-work variations) for the #include virtual=..., and none of them worked. The file was found at the path cgi/tipweek.pl when I used #include file="cgi/tipweek.pl" (which pulls all the code into the HTML page), but then changing "file" to "virtual".. . didn't work. And the file is found at cgi/tipweek.pl for the img source.

At this point, I have to think that some setting on the server is causing the problem. I've sent this on to our system gurus. They know I've found something that works, but I'm hoping they will look into this to give me a more fitting solution. (Maybe they'll turn on CMD so that #exec cmd works? I can hope!)

'Tis a puzzlement, but at least it appears I can put this into production on Monday as I'd hoped (assuming I finish everything else I've had to neglect while I worked on this one little bit...).
Sep 5 '07 #14
KevinADC
4,059 Recognized Expert Specialist
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.

Attach your perl script to a post and if I get a chance I will look at it.
Sep 5 '07 #15
owlice
13 New Member
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...)
Sep 6 '07 #16
owlice
13 New Member
So my next question is: should I let the goat off the hook now, or wait until everything's in production? :-D
Sep 6 '07 #17
KevinADC
4,059 Recognized Expert Specialist
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.
Sep 6 '07 #18
owlice
13 New Member
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.
Sep 6 '07 #19
owlice
13 New Member
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
File Type: txt tipweekforposting.pl.txt (16.1 KB, 462 views)
Sep 13 '07 #20

Sign in to post your reply or Sign up for a free account.

Similar topics

41
3548
by: Xah Lee | last post by:
here's another interesting algorithmic exercise, again from part of a larger program in the previous series. Here's the original Perl documentation: =pod merge($pairings) takes a list of pairs, each pair indicates the sameness of the two indexes. Returns a partitioned list of same indexes.
6
10521
by: Pierre-Yves | last post by:
Hello, I would like to prevent my perl program to be executed several times simultaneously (if the program is already running, I would like to display a message like "another instance of this program is already running, please try again in a couple of minutes). For doing this, I guess I have to check the running processes... but I don't know how to do that and how I can identify my program in the running processes.
12
1728
by: SStory | last post by:
Doing pages for contract..... If I make an ASPX file that does certain things, how simple would it be for a person who know nothing about it to modify the user interface without bothering the ASPX interaction? How would I best build such pages. Many people of course don't want a page that they can't modify at all without programmer intervention. I think ASPX does this. Just curious to hear some comments on the subject from more...
0
9739
by: Kirt Loki Dankmyer | last post by:
So, I download the latest "stable" tar for perl (5.8.7) and try to compile it on the Solaris 8 (SPARC) box that I administrate. I try all sorts of different switches, but I can't get it to compile. I need it to be compiled with threads. Anyone have any wisdom on how best to do this? Here's a transcript of my latest attempt. It's long; you might want to skip to the bottom, where I try "make" and the fatal errors start happening.
21
34413
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most obvious of which is the sharing of files. For example, you upload images to a server to share them with other people over the Internet. Perl comes ready equipped for uploading files via the CGI.pm module, which has long been a core module and allows users...
5
2333
by: Robert Latest | last post by:
Hello, if HTML authoring includes HTML autogeneration, this request is on-topic. Otherwise please forgive me and point me in the right direction. I'd like to make a bunch of dirs full of files available on a web server. Of course I could just leave them like they are and have the server take care of the listings. I don't like that because the listing is entirely server-dependent, if the server allows dir listings at all. On the server...
22
2922
by: Dan Rumney | last post by:
Hi all, I've been writing Javascript for quite a while now and have, of late, been writing quite a lot of AJAX and AJAX-related code. In the main, my dynamically generated pages are created using Perl on the backend, with Javascript providing limited frontend functionality. As an example, an expanding tree would be fully populated on the server-side and then presented to the browser, with Javascript and CSS being used to vary the...
10
6971
by: happyse27 | last post by:
Hi All, I got this apache errors(see section A1 and A2 below) when I used a html(see section b below) to activate acctman.pl(see section c below). Section D below is part of the configuration of section c. Not sure where went wrong as the web page displayed internal server error. Also, what is the error 543? and error 2114. Where to find the list of errors in websites as it is not the standard apache error. I could not find...
1
47462
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click on a link and after a moment or two a file download dialog box pops-up in your web browser and prompts you for some instructions, such as “open” or “save“. I’m going to show you how to do that using a perl script. What You Need Any recent...
0
8683
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9170
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9031
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8876
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6531
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5867
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.