The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,685 other followers

Archive for December 19th, 2012

Two great articles from ploeh blog on temporal compatibility (Rangers and Zookeepers, Zookeepers must become Rangers)

Posted by jpluimers on 2012/12/19

Must read: why you want temporal compatibility.

  1. ploeh blog – Zookeepers must become Rangers.
  2. ploeh blog – Rangers and Zookeepers.

–jeroen

Posted in Development, Software Development | Tagged: , , | Leave a Comment »

batch file example: Redirect stderr and stdout through pipe

Posted by jpluimers on 2012/12/19

I knew that 2>&1 was needed to redirect both stderr and stdout, but for piping, it cannot be at the end of the line. This works in the categories shown at the bottom of the post.

Rob van der Woude again to the rescue in redirection:

(4) Redirecting both standard output and standard error to the same file or device is done by adding 2>&1 to the command line. This will only work in OS/2 and NT, not in MS-DOS.
Where you put 2>&1 is rather critical. It will only do what it is supposed to do when placed at the end of the command line (as Jennie Walker pointed out to me) or right before the next pipe ( | ).

Example: batch file that checks if a few NarrowCast machines are indeed on-line and logged on with the right user.

It uses PsLoggedOn to verify who is logged on, and Explorer to show a hidden share.

The pipe is needed to verify there is indeed a domain user logged on.

@echo off
  for %%m in (Machine1 Machine2 Machine3) do call :show %%m
  goto :pause

:show
  echo %1
  %~dp0PsLoggedOn -L \\%1 2>&1 | find /I "MYDOMAIN\"
  start explorer /e,\\%1\NarrowCast$
  goto :end

:pause
  pause
:end

–jeroen

Posted in Batch-Files, Development, Power User, Scripting, Software Development, Windows, Windows 7, Windows Server 2003, Windows Server 2008, Windows Vista, Windows XP | 4 Comments »

 
%d bloggers like this: