Chinaunix

标题: 请问:如何让perl在后台运行呢 [打印本页]

作者: iuytr123    时间: 2010-10-28 18:00
标题: 请问:如何让perl在后台运行呢
我有个perl程序,操作系统是:windows2003 server,配了个计划任务,每天执行这个perl程序,但是每次执行的时候,都会弹出个一个DOS窗口执行。。但是同样的程序,在一个装有window2000 server的机器上,就不会弹出窗口,请问是操作系统的原因,还是perl可以控制的,perl有没有类似Linux里面加一个&让它在后台运行的功能                  谢谢
作者: zhlong8    时间: 2010-10-28 18:44
本帖最后由 zhlong8 于 2010-10-28 18:49 编辑

默认打开方式改为 wperl,或者像我新建种文件类型叫 plw 专用应付这种情况的

或者你的计划任务命令用 wperl xxx.pl,而不是 perl xxx.pl 或 xxx.pl
作者: iuytr123    时间: 2010-10-28 19:12
呵呵,非常感谢。我在perl安装程序的bin目录下找到了wperl
作者: x9x9    时间: 2010-10-28 23:14
默认打开方式改为 wperl,或者像我新建种文件类型叫 plw 专用应付这种情况的  

或者你的计划任 ...
zhlong8 发表于 2010-10-28 18:44


不错,学习了~
Google了一下,好像应该是.wpl格式~

The wperl.exe command under Windows starts Perl without attaching it to a console. This means that if you associate for example the file extension .wpl with wperl.exe, double-clicking test.wpl will not pop up a console window with text scrolling by. This is very convenient if your Perl script is written using Win32::GUI or some other windowing toolkit.

Using wperl.exe and thus not having a console attached also has a drawback - STDIN,STDOUT and STDERR are not available, so you will need to reopen them to some log files if you output any text via print or warn.

顺手翻个大意:
  
Windows下的wperl.exe命令在启动Perl时没有将之关联到一个控制台。意为假如你将一个文件的扩展名设为.wpl和wperl.exe关联起来的话,双击 test.wpl 将不会弹出一个滚动着文本的控制台窗口。这样如果你的Perl脚本使用了Win32::GUI或其它带窗口的工具时将会非常方便。
  但使用wperl.exe 不和控制台进行关联也有它的弊端,STDIN,STDOUT 和 STDERR将不存在,因此如果你想通过print或warn输出任何文本时就需要重新打开它们到某个log文件。

作者: zhlong8    时间: 2010-10-29 11:36
它没自己注册这个格式,我估计太敬仰 flw 了,自己发明种文件格式




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2