如何在 Windows XP 上使用 Perl 运行可执行文件?
如何使用perl运行可执行文件?
例如,我想运行一个普通的 notepad.exe。我怎样才能做到这一点?
这就是我所得到的:
my @args = system("notepad.exe");
system(@args) == 0 or die "system @args failed: $?";
但它返回:
Can't spawn "cmd.exe": No such file or directory blah blah blah.
我缺少什么?
How to run an executable file using perl?
For instance, i want to run a plain notepad.exe. How could I achieve this?
This is what I've got:
my @args = system("notepad.exe");
system(@args) == 0 or die "system @args failed: $?";
But it returns:
Can't spawn "cmd.exe": No such file or directory blah blah blah.
What am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你的代码看起来有点混乱。您可能想要的是类似
system
返回单个值,而不是数组。有关详细说明,请参阅perldoc -f system
。perlmonks 上的这个帖子讨论了您在提供一些不同解决方案时遇到的错误。
这个答案是我原来的评论的延伸。抱歉,如果这是多余的。
Your code seems a bit confused. What you probably want is something like
system
returns a single value, not an array. Seeperldoc -f system
for a detailed description.This thread on perlmonks discusses the error you're getting with a few different solutions being presented.
This answer is an extension of my original comment. Sorry if it's superfluous.
试试这个。
Try this.
这是 Perl 内部错误,可能是由损坏的环境引起的。 Perl 找不到 Windows shell
cmd.exe
,该 shell 在幕后用于运行传递给system
的程序。使用进程监视器等实用程序来查看操作系统级别发生的情况。
This is a Perl internal error probably caused by a broken environment. Perl can't find the Windows shell
cmd.exe
that is used under the hood to run the program passed tosystem
.Use some utility as Process Monitor to see what's going on at the OS level.