Supress从TASKKILL打印 [英] Supress prints from TASKKILL

查看:257
本文介绍了Supress从TASKKILL打印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在写一个Perl脚本,使得系统调用可以终止正在运行的进程。例如,我想杀死所有PuTTy窗口。为此,我有:

I'm writing a Perl script that makes system calls to kill running processes. For instance, I want to kill all PuTTy windows. In order to do this, I have:


系统('TASKKILL / F / IM putty * / T 2> nul' / p>

system('TASKKILL /F /IM putty* /T 2>nul');

然而,对于被杀死的每个进程,我得到一个打印

For each process that's killed, however, I get a print saying


SUCCESS:PID xxxx的PID xxxx子进程的进程已终止。

SUCCESS: The process with PID xxxx child of PID xxxx has been terminated.

。什么是一个简单的方法来消除这些打印?还要注意,我在Cygwin中执行这些脚本。

which is cluttering my CLI. What's an easy way to eliminate these prints? Also note, that I'm executing these scripts in Cygwin.

推荐答案

重定向sderr-> stdout-> nul:

Redirect sderr->stdout->nul:

system('TASKKILL /F /IM putty* /T 1>nul 2>&1');

或只是简单地抓取输出:

or just simply grab output:

my $res = `TASKKILL /F /IM putty* /T 2>nul`;

这篇关于Supress从TASKKILL打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆