我怎样才能摆脱Perl中的STDERR
发布时间:2020-12-15 21:51:57 所属栏目:大数据 来源:网络整理
导读:我在Perl中使用了一些系统命令. 在下面的例子中,我获得如下输出: ls: import-log.*: No such file or directoryls: error-log.*: No such file or directoryNo specified files found for deletion 我的代码: sub monthoryear() { @importlog = `ls -al im
我在Perl中使用了一些系统命令.
在下面的例子中,我获得如下输出: ls: import-log.*: No such file or directory ls: error-log.*: No such file or directory No specified files found for deletion 我的代码: sub monthoryear() { @importlog = `ls -al import-log.*`; @errorlog = `ls -al error-log.*`; } 即使没有文件,我也不希望在输出中看到以下内容. ls: import-log.*: No such file or directory & ls: error-log.*: No such file or directory 解决方法
您可以在subshel??l命令中添加stderr重定向:
@importlog = `ls -al import-log.* 2>/dev/null`; @errorlog = `ls -al error-log.* 2>/dev/null`; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |