PriNet has asked for the wisdom of the Perl Monks concerning the following question:

Ok, again, I'm about to drive myself crazy. I am developing a new website with https that has alot of dynamic content to which I resort to perl (primarily) and javascript. My problem is, I need a "backend.pl" program to start up when you go (connect) to the website (if there isn't already an instance running) that monitors conditions happening on the website (ie; connections and disconnections), and shuts down (I can deal with this later, I just need to be sure there is only one instance running) the "backend.pl" program when no one is on the website until someone connects to the website again and starts up again (I'm getting all this information and it works when I start the script manually). I hope this is a good explanation of what I'm trying to do, I have the "backend.pl" program scripted up, and it works good, but I have to start it manually to get it to do it's job. I have spent several hours now trying fork, exec, system, win32::process in several configurations, but, I cannot get a command prompt window to open up on the server (from the server) so to display the messages that are generated by the monitoring script. again it "displays/runs" fine when I start the script from a command prompt window that I open manually and "perl backend.pl". And, so far, none of the options I mentioned actually open a window on the server. Does anyone have any idea how I can "open a command prompt" window from the perl script on the server so that I can "print STDOUT" messages to "this" window so I can see the "monitoring" programs output? I can provide more information if needed, I'm just stumped on this "open a command prompt window" like when I manually open a command prompt window on the server to start the script.

I tried re-inventing the wheel again, but everytime I push it, it still falls flat on it's side...
  • Comment on Open Command Prompt From Script To Run/View Another Scripts Output

Replies are listed 'Best First'.
Re: Open Command Prompt From Script To Run/View Another Scripts Output
by Anonymous Monk on Apr 18, 2016 at 06:07 UTC
    On a server you normally can't assume someone is logged in all the time, so your server process is bound to fail at creating a window one way or another. The normal way to go about what you want to do is write messages to a log, and when someone is logged into the server and wants to see the messages, they tail the logfile (or equivalent), in other words the user launches the viewer process instead of the server. Another solution is that the server process can provide a socket that the "log viewer/control" program can connect to, and the server writes messages there and optionally receives commands. Also, why not have your "backend.pl" running continually?