Well, it's possible this may not work in your particular case, but I wanted to offer this -- are you certain that you can't move your CGI script code into modules of some sort? If you were capable of doing that -- instead of using an expensive fork call, you could do a simple subroutine call, and just pass parameters that way.
Another benefit of that method is that it makes it even simpler to move to something like mod_perl. If you're calling 20 CGI programs, the cost of that could be huge.. but if they were Perl modules loaded in mod_perl, the cost of that would actually be quite negligable, aside from RAM considerations. Slashdot uses more modules then that, and they were about the only news site that survived last Tuesday :-)
If this doesn't work for you, perhaps you could give some more details about the project you are working on. Good luck!
-Eric | [reply] |
Ok, I better explain exactly what I'm doing. I have a template-based website maintenance system. It stores the contents of a web page in text files, which allows the user to update a text file and click a generate button to make it into a web page. The system is a bit more complex than that, but that describes the function in a nutshell. The problem comes in when the text file that holds the menu is changed. The user would then have to click the generate button on each page. What I want to do is make a script that could run all of the scripts so the user didn't have to do that. The script would simply have to call each CGI script like this:
perl update.cgi?action=generate
to cause the scripts to generate the pages. Speed isn't so much of a problem because very few people would be updating the site. I hope that clarifies some things. If there are other issues I should clarify, please just let me know. Thanks! | [reply] [d/l] |
Thanks for the further explanation. It sounds like you have a problem with mixing interface and implementation. One of my preferred ways to design CGI programs is to have a module that implements the actual functionality and then a CGI front-end that calls that module. If you write your code this way, it's trivial to write a command-line front-end for the module when you need it or to simply call it from another module.
If you can't deal with that right now and you want a quick and dirty solution, the simplest approach is to use LWP to make additional calls to the server and run the other CGIs. You could simulate a CGI environment by setting environment variables and executing the other programs, but if speed is not an issue there's no reason to do the additional work.
| [reply] |
Twenty? It sound like their is a Better Way. Can you tell us some more about the problem space of what you are trying to do?
Why would you want to fire off 20 CGIs at the same time?
redmist
Purple Monkey Dishwasher
| [reply] |