perl运行其他程序的5种方法
2013-06-17 21:23
183 查看
1.使用system函数 运行成功,返回0,运行失败则返回非负整数
system("cmd");
2.使用qx
my $cmd1=qx/date/;
3.使用`` 与qx等效
4.使用open函数
open(CMD,“ifconfig |”) or die $!
my @result=<CMD>;
close(CMD);
5.使用readpipe函数
使用readpipe函数可以获取外部程序运行的结果,比如运行 ls 会列出当前目录的文件和文件夹,
my $result=readpipe("ls ");
system("cmd");
2.使用qx
my $cmd1=qx/date/;
3.使用`` 与qx等效
4.使用open函数
open(CMD,“ifconfig |”) or die $!
my @result=<CMD>;
close(CMD);
5.使用readpipe函数
使用readpipe函数可以获取外部程序运行的结果,比如运行 ls 会列出当前目录的文件和文件夹,
my $result=readpipe("ls ");
#!/usr/bin/perl use strict; my $return=system("date"); print "this is system function , successful:return $return\n"; $return=system("not_exist"); print "this is sysyem function failed,return $return\n"; #use qx my $cmd1=qx/pwd/; print "this time use qx $cmd1"; #qx=`` my $cmd2=`pwd`; print "this time use \`\` $cmd2 "; open(CMD,"echo \"\$(date +\%Y\%m\%d)\"|") or die $!; my @result=<CMD>; close(CMD); print @result; my $result=readpipe("ls -rtl"); print $result;
相关文章推荐
- Perl运行其他程序的5种方法
- C# .NET Winform等程序一运行就闪退 不同环境 换到其他电脑,例如XP之类的解决方法。
- python运行其他程序的实现方法
- 基于VSCode环境的三种使用Python运行其他程序方法
- VC程序中运行其他程序的三种方法
- DELPHI 5种运行程序的方法具体应用实例(带参数)
- MFC 程序不依赖.NET的设置方法 使自己写的程序可以在其他上电脑运行
- Perl中调用其他程序的方法
- 让程序只运行一个实例的5种方法
- VC程序中运行其他程序的三种方法
- Perl 调用其他程序方法
- Perl调用其他程序方法
- VC++ 提高C++程序运行效率10个简单方法(其他语言程序参考)
- vc程序中运行其他程序和创建文件夹的方法:
- VC程序中运行其他程序的三种方法(转)
- BCB编译成功的程序在其他机子上运行时提示vcl60.bpl找不到的解决方法
- 5种运行程序的方法具体应用实例(带参数)
- C# 程序只运行一次的处理方法
- C#获取项目程序及运行路径的方法
- 如何在开始运行中运行其他程序