Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problems with the Pipe operator and 2>nul

27 views
Skip to first unread message

John Gray

unread,
Sep 26, 2016, 5:26:34 AM9/26/16
to
I am trying to remove the banner lines from the PsInfo system information tool, but am getting what seems to me to be anomalous results.

I further want to restrict the output from PsInfo to specific lines, for which my usual FINDSTR string is "information Format NTFS".

In the test example, I am simply searching for the letters e and i, to select all (or almost all!) the lines passed to FINDSTR.

The batch file is:

psinfo -d disks 1>nul 2>con
psinfo -d disks 2>nul
psinfo -d disks 2>nul | findstr "e i"

and the output is

-----------

D:\>psinfo -d disks 1>nul

PsInfo v1.78 - Local and remote system information viewer
Copyright (C) 2001-2016 Mark Russinovich
Sysinternals - www.sysinternals.com

Querying information for OnesPC...

D:\>psinfo -d disks 2>nul
System information for \\OnesPC:

Volume Type Format Label Size Free Free
C: Fixed NTFS OnesPC_C 49.43 GB 20.45 GB 41.4%
D: Fixed NTFS OnesPC_D 25.00 GB 24.05 GB 96.2%
V: CD-ROM 0.0%

D:\>psinfo -d disks 2>nul | findstr "e i"
PsInfo v1.78 - Local and remote system information viewer
Copyright (C) 2001-2016 Mark Russinovich
Sysinternals - www.sysinternals.com
Querying information for OnesPC...

System information for \\OnesPC:
Volume Type Format Label Size Free Free
C: Fixed NTFS OnesPC_C 49.43 GB 20.45 GB 41.4%
D: Fixed NTFS OnesPC_D 25.00 GB 24.05 GB 96.2%

----------

The result for the final execution appears to me that the Pipe operator is taking the data from both stream 1 (SYSLOG) AND stream 2 (SYSERR), in spite of stream 2 having been redirected to NUL.

Is this another instance where I have misunderstood how things work?

foxidrive

unread,
Sep 26, 2016, 5:39:55 AM9/26/16
to
On 26/09/2016 19:26, John Gray wrote:
> I am trying to remove the banner lines from the PsInfo system information tool, but am getting what seems to me to be anomalous results.
>
> D:\>psinfo -d disks 2>nul | findstr "e i"
> PsInfo v1.78 - Local and remote system information viewer
> Copyright (C) 2001-2016 Mark Russinovich
> Sysinternals - www.sysinternals.com
> Querying information for OnesPC...
>
> System information for \\OnesPC:
> Volume Type Format Label Size Free Free
> C: Fixed NTFS OnesPC_C 49.43 GB 20.45 GB 41.4%
> D: Fixed NTFS OnesPC_D 25.00 GB 24.05 GB 96.2%


V1.77 works like this here - is this what you wanted?

psinfo -d disks 2>nul|findstr "information Format NTFS"

System information for \\ME:
Volume Type Format Label Size Free Free
C: Fixed NTFS Drive C 223.57 GB 54.39 GB
D: Fixed NTFS Drive D 1863.01 GB 83.13 GB
E: Fixed NTFS New Volume 447.13 GB 5.28 GB


=========
I removed the free % as it wrapped the text here.

John Gray

unread,
Sep 26, 2016, 2:18:15 PM9/26/16
to
Unfortunately I only have PsInfo 1.78 (whatever it says on the website!), and I get the same results as I described on both Windows Server 2008 R2 (64-bit) and Windows 10 AU (64-bit) with both PsInfo.exe and PsInfo64.exe.

I will see if I can find a v1.77 version of PsInfo somewhere...

Herbert Kleebauer

unread,
Sep 26, 2016, 3:19:51 PM9/26/16
to
On 26.09.2016 20:18, John Gray wrote:

>
> Unfortunately I only have PsInfo 1.78 (whatever it says on the website!),

Strange behavior, independent of the version.

PsInfo.exe 1>con 2>nul | more

doesn't displays the header lines whereas

PsInfo.exe 2>nul | more

does display them.


Don't try to understand it, just use

PsInfo.exe 1>con 2>nul | findstr

John Gray

unread,
Sep 26, 2016, 3:40:30 PM9/26/16
to
That's remarkable, and it works - my profound thanks!

foxidrive

unread,
Sep 26, 2016, 3:45:19 PM9/26/16
to
I was curious so I looked a little further here.
This is the output from V1.78 32 bit under Windows 8.1

With >con
===============
psinfo -d disks 1>con 2>nul|findstr "information Format NTFS"
System information for \\ME:

Volume Type Format Label Size Free Free
C: Fixed NTFS Drive C 223.57 GB 51.48 GB
D: Fixed NTFS Drive D 1863.01 GB 83.52 GB
E: Fixed NTFS New Volume 447.13 GB 1.60 GB
==============

Without the 1>con it shows one header line - but there is an added blank
line above, and it's missing the two trailing .. after the PC name.

I'm not going to lose sleep over it - I just noticed and thought I'd
comment on an extra oddity.

without 1>con
==============
psinfo -d disks 2>nul|findstr "information Format NTFS"
PsInfo v1.78 - Local and remote system information viewer
System information for \\ME:..
Volume Type Format Label Size Free Free
C: Fixed NTFS Drive C 223.57 GB 51.48 GB
D: Fixed NTFS Drive D 1863.01 GB 83.52 GB
E: Fixed NTFS New Volume 447.13 GB 1.60 GB
==============

0 new messages