Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - stderr from external program to write-error

Reply
 
Old 09-11-2009   #1 (permalink)
wofat68


 
 

stderr from external program to write-error

Hi,

I have the following problem: my PS script calls an external program
(actually a template processor). The external program writes error
messages to stderr. I have verified this by redirecting output with
2>err.txt. When running the PS script, the error messages from the
external program are easily overlooked because they are obviously
written to the PS output pipeline rather than to the error pipeline.
To say it another way: I would like the error message from the
external program appear as red on black as if they written with Write-
Error.

I'm using PS only occasional and I wasn't able to find a solution or
even a "best practice" how to handle errors from external programs.

Any help?

Thanks a lot.


My System SpecsSystem Spec
Old 09-11-2009   #2 (permalink)
Marco Shaw [MVP]


 
 

Re: stderr from external program to write-error

If you're stuck with PowerShell v1, I believe you are out of luck. If
you're considering v2, then check this as it may help:
http://www.nivot.org/2009/08/19/Powe...gerModule.aspx

Oisin mentioned he was planning to add even more features to the above.

Marco

"wofat68" <atlanticcoast2006@xxxxxx> wrote in message
news:b0b54f4f-23c1-4db2-9150-3b7af4073996@xxxxxx
Quote:

> Hi,
>
> I have the following problem: my PS script calls an external program
> (actually a template processor). The external program writes error
> messages to stderr. I have verified this by redirecting output with
> 2>err.txt. When running the PS script, the error messages from the
> external program are easily overlooked because they are obviously
> written to the PS output pipeline rather than to the error pipeline.
> To say it another way: I would like the error message from the
> external program appear as red on black as if they written with Write-
> Error.
>
> I'm using PS only occasional and I wasn't able to find a solution or
> even a "best practice" how to handle errors from external programs.
>
> Any help?
>
> Thanks a lot.
>
My System SpecsSystem Spec
Old 09-11-2009   #3 (permalink)
wofat68


 
 

Re: stderr from external program to write-error

On Sep 11, 5:19*pm, "Marco Shaw [MVP]" <marco.shaw@xxxxxx_SPAMgmail.com>
wrote:
Quote:

> If you're stuck with PowerShell v1, I believe you are out of luck. *If
> you're considering v2, then check this as it may help:http://www.nivot.org/2009/08/19/Powe...leAndFlexibleS...
Indeed, I'm stuck with PS v1 for while. Thanks anyway.

My idea was to redirect stderr to a PS variable for later analysis and
output with Write-Error. I played around with Invoke-Expression and
the -ErrorVariable parameter. No success so far. I'm probably doing
something wrong here. Documentation is quite sparse. Is there at least
a way to catch stderr without redirecting to a temporary file? That
would be an enormous help.

Thanks.

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
External USB HDDs - Write Caching General Discussion
Write-Error doesn't write anyting PowerShell
External HDD drive write protected on vistax64 Vista hardware & devices
No write-access from Vista to files created by XP on external driv Vista account administration
Unable to write files to iPod or external hard drive. Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46