禁止从任务栏打印照片 [英] Suppress prints from TASKKILL

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

问题描述

我正在编写一个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:

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

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

但是,对于每个被杀死的进程,我都会看到一句话:

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

成功:PID xxxx子级为PID xxxx的子进程已终止.

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

这使我的CLI混乱.消除这些印刷痕迹的简便方法是什么?另外请注意,我正在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`;

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

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