Hallo everyone,
After playing around with 'fork' in order to try to get a one process to monitor another, I have changed my tack and switched to Win32::Process. Indeed, it looks like this function will be able to do what I require:
A: Start a windows application
B: While that application is running regularly monitor a log file
C: If the windows application falls over or locks up, then the monitor process will kill the job and close the script cleanly, supplying an error code as return.
However, I am having some issues with the syntax and find that although I can use Win32::Process: :Create to open the program I require (in this test 'notepad'), I find that the target file (here: nptest.txt) will not open. I just get a blank text document.
Here is a sample of my code ...
my $ProcessObj;
Win32::Process: :Create($Proces sObj,
"C:\\WINDOWS\\s ystem32\\notepa d.exe",
"C:\\Temp\\npte st.txt",
0,
NORMAL_PRIORITY _CLASS,
"C:\\Temp") or die ErrorReport();
I have tried all kinds of variations in the path but couldn't get it to open the target file. I find this bizarre as the application itself (notepad and other windows applications) opens fine ... but not the target.
It must be some simple thing that I have missed but I have checked back with examples from the web and I just can't see it. Maybe a second pair of eyes will see what I have missed?
Or maybe you can suggest an alternative command/syntax/process for getting one (repeating) process to monitor another (long) process?
I'd be very grateful for any tips or thoughts that you have.
Regards and thanks,
Alan Searle.
(NB: The double backslashes are necessary otherwise notepad won't open)
After playing around with 'fork' in order to try to get a one process to monitor another, I have changed my tack and switched to Win32::Process. Indeed, it looks like this function will be able to do what I require:
A: Start a windows application
B: While that application is running regularly monitor a log file
C: If the windows application falls over or locks up, then the monitor process will kill the job and close the script cleanly, supplying an error code as return.
However, I am having some issues with the syntax and find that although I can use Win32::Process: :Create to open the program I require (in this test 'notepad'), I find that the target file (here: nptest.txt) will not open. I just get a blank text document.
Here is a sample of my code ...
my $ProcessObj;
Win32::Process: :Create($Proces sObj,
"C:\\WINDOWS\\s ystem32\\notepa d.exe",
"C:\\Temp\\npte st.txt",
0,
NORMAL_PRIORITY _CLASS,
"C:\\Temp") or die ErrorReport();
I have tried all kinds of variations in the path but couldn't get it to open the target file. I find this bizarre as the application itself (notepad and other windows applications) opens fine ... but not the target.
It must be some simple thing that I have missed but I have checked back with examples from the web and I just can't see it. Maybe a second pair of eyes will see what I have missed?
Or maybe you can suggest an alternative command/syntax/process for getting one (repeating) process to monitor another (long) process?
I'd be very grateful for any tips or thoughts that you have.
Regards and thanks,
Alan Searle.
(NB: The double backslashes are necessary otherwise notepad won't open)
Comment