![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Help with stderr from native console application I’m trying to process the results of a native windows console application. The application returns some xml in stdout if successful, or an error to stderr if not. Ultimately, I would like a script that returns an [xml] object, or a single error depending upon whether the console application succeeded or not. I have gotten as far as: [xml] [string]::join("`n", ( svn info --xml )) Which works great if svn.exe succeeds, but not so great if it fails. If it fails I get the following output: svn: '.' is not a working copy Cannot convert value "<?xml version="1.0" encoding="utf-8"?> <info>" to type "System.Xml.XmlDocument". Error: "Unexpected end of file has occurred. The following elements are not closed: info. Line 2, position 7." At line:1 char:21 + [xml] [string]::join( <<<< "`n", ( svn info --xml )) The second error occurs because even when svn fails, it outputs invalid xml. What I really want is a single error “svn: '.' is not a working copy” I have tried varying combinations of $ErrorActionPreference, and invoke-expression with –ErrorAction to no avail. I think the root of the problem is that I don’t understand how stderr is handled in PowerShell. Can anyone help? Thanks, - Michael |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: Help with stderr from native console application "Michael Lynch" <adoptableCoho@community.nospam> wrote in message news:C3A9689A-BDE7-4CAF-9B74-F7DF74160679@microsoft.com... > I’m trying to process the results of a native windows console application. > The application returns some xml in stdout if successful, or an error to > stderr if not. Ultimately, I would like a script that returns an [xml] > object, or a single error depending upon whether the console application > succeeded or not. > > I have gotten as far as: [xml] [string]::join("`n", ( svn info --xml )) Try this: [xml] [string]::join("`n", ( svn info --xml 2>$null )) or if you want to capture the errors [xml] [string]::join("`n", ( svn info --xml 2>SvnStderr.txt )) This will redirect stderr to somewhere else besides the regular output. You can look at $LastExitCode to make sure that Svn worked that is, if the type cast to XML doesn't already error. -- Keith |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Unhandled Exception in Console Application | AG | .NET General | 10 | 04-10-2008 09:20 AM |
| ImageList for Console Application | jp2msft | .NET General | 8 | 03-20-2008 05:19 PM |
| Creative Console Launcher 2.40.09 Application for X-Fi Series | Cal Bear '66 | Vista General | 0 | 09-08-2007 07:20 AM |
| Creative Console Launcher 2.40.09 Application for X-Fi Series | Cal Bear '66 | Vista music pictures video | 0 | 09-08-2007 07:20 AM |
| Application Compatibility SMS 2003 Admin Console | Mario | Vista General | 0 | 03-30-2007 11:42 AM |