Chinaunix

标题: 怎么才能用Win32::Process启动另外一个perl脚本呢? [打印本页]

作者: jieshuzheng    时间: 2009-03-10 17:47
标题: 怎么才能用Win32::Process启动另外一个perl脚本呢?
c:\>perl -v

This is perl, v5.10.0 built for MSWin32-x86-multi-thread
(with 5 registered patches, see perl -V for more detail)

Copyright 1987-2007, Larry Wall

Binary build 1004 [287188] provided by ActiveState http://www.ActiveState.com
Built Sep  3 2008 13:16:37

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

C:\>cat test.pl
use strict;
use warnings;
use Win32:rocess;

my $processObj;
Win32:rocess::Create( $processObj,
                        'c:\perl\bin\perl.exe',
                        'C:\child.pl',
                        0,
                        NORMAL_PRIORITY_CLASS,
                        "." ) || die "$! Cannot create process.";

$processObj->Wait(INFINITE);

print "process($$) parent terminates.\n";

C:\>cat child.pl
use strict;
use warnings;

print "process($$) child terminated\n";
exit(0);

C:\>test.pl
child.pl得不到运行,好像命令行参数C:\>child.pl没有能传给新创建的进程。新创建的perl.exe在stdin等待输入perl脚本。
作者: DQP    时间: 2009-03-10 17:47

  1. Win32::Process::Create( $processObj,
  2. ........
  3.                         'C:\child.pl',
  4. .............
复制代码

改为

  1. Win32::Process::Create( $processObj,
  2. ........
  3.                         'perl C:\child.pl',
  4. .............
复制代码

[ 本帖最后由 DQP 于 2009-3-10 21:27 编辑 ]




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