本文介绍了Win32 :: Process ...目标问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 大家好, 在玩''fork''以试图让一个进程监视另一个进程之后,我已经改变了我的方向并切换到了Win32: :处理。实际上,看起来这个功能可以满足我的要求: A:启动一个Windows应用程序 B:该应用程序定期运行监视日志文件 C:如果Windows应用程序崩溃或锁定,则监视进程将终止作业并干净地关闭脚本,并提供错误代码作为返回。 但是,我遇到了一些语法问题并发现虽然我可以使用Win32 :: Process :: Create来打开我需要的程序(在这个测试''notepad''中),我发现目标文件(此处:nptest.txt)将无法打开。我只是得到一个空白文本文件。 这是我的代码示例... 我的$ ProcessObj; Win32 :: Process :: Create($ ProcessObj, " C:\\WINDOWS \\ system32 \\\\otepad.exe", " C:\\Temp \\\\ptest.txt", 0, NORMAL_PRIORITY_CLASS, C:\\Temp或者死于ErrorReport(); 我在路径中尝试了各种变化但是无法打开目标文件。我发现这个奇怪的是应用程序本身(记事本和其他Windows应用程序)打开正常...但不是目标。 这一定是一些简单的事情,我错过了但我有用网上的例子回来看看,我看不到它。也许第二双眼睛会看到我错过了什么? 或许你可以建议另一个命令/语法/过程让一个(重复)过程监视另一个(长)过程? 我会非常感谢您提供的任何提示或想法。 致敬和谢谢, Alan Searle。 (注意:双反斜杠是必要的,否则记事本不会打开)解决方案 ProcessObj; Win32 :: Process :: Create( ProcessObj, " C:\\ WINDOWS \\system32 \\\\otepad.exe", " C:\\Temp \\\\ptest.txt", 0, NORMAL_PRIORITY_CLASS, " C:\\Temp")或者死了ErrorReport(); 我试过路径中的各种变化,但无法打开目标文件。我发现这个奇怪的是应用程序本身(记事本和其他Windows应用程序)打开正常...但不是目标。 这一定是一些简单的事情,我错过了但我有用网上的例子回来看看,我看不到它。也许第二双眼睛会看到我错过了什么? 或许你可以建议另一个命令/语法/过程让一个(重复)过程监视另一个(长)过程? 我会非常感谢您提供的任何提示或想法。 致敬和谢谢, Alan Searle。 (注意:双反斜杠是必要的,否则记事本不会打开) 尝试使用wordpad测试。 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 applicationB: While that application is running regularly monitor a log fileC: 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($ProcessObj,"C:\\WINDOWS\\system32\\notepad.exe","C:\\Temp\\nptest.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) 解决方案 ProcessObj;Win32::Process::Create(ProcessObj,"C:\\WINDOWS\\system32\\notepad.exe","C:\\Temp\\nptest.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)try using wordpad for the test. 这篇关于Win32 :: Process ...目标问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-05 00:02