免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2962 | 回复: 1
打印 上一主题 下一主题

怎么才能用Win32::Process启动另外一个perl脚本呢? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-03-10 17:47 |只看该作者 |倒序浏览
5可用积分
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-3-10 21:27 编辑 ]

论坛徽章:
0
2 [报告]
发表于 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 编辑 ]
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP