![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
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 | Redirection and discarding of error objects Bruce Payette's book, page 259, has an example showing capturing error info in a variable other than $error, and suppressing the errors being displayed: PS> dir nofuss, nomuss, nobother -ErrorVariable errs 2>$null Obviously, these are non-existing files and indeed $errs.count equals 3. However, I do not understand the constant 2 in the command. If I leave it out, or fill in some other number, the errors are sent to the console. What's the magic of 2 here, why 2? It must be something simple I overlooked, or is it just time for coffee? Thanx, Hans |
My System Specs![]() |
| | #2 (permalink) | ||||||||||||||||||||||||||||||||||||
| Guest | Re: Redirection and discarding of error objects "Hans Dingemans" <hans_dingemans@xxxxxx> wrote in message news:%23mxy$u0$HHA.4496@xxxxxx
2> is the standard notation for error output (ie where to send error messages), as 1> or > is for standard output. So in that particular case no errors appear on the screen, since they're sent to '$null', but they are sent to the variable $errs. The following is taken from the output from this command, and may help get-help about_Operator Redirection Operators 2>&1 Add errors to results 1>&2 Add results to errors
< Input from (not supported) 2>> Append errors to a file 2> Errors from operation are directed to named file, previous file contents are overwritten -- Jon | ||||||||||||||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||||||||||||||
| | #3 (permalink) | ||||||||||||
| Guest | Re: Redirection and discarding of error objects On Sep 25, 3:11 pm, "Hans Dingemans" <hans_dingem...@xxxxxx> wrote:
isn't a constant '2' in the command. The number 2 is used for historical reasons, I assume; the handle for the standard error I/O stream on a Unix system is 2. You can read about all of the redirection operators supported by PowerShell starting on page 138 of Bruce's book. Jeff | ||||||||||||
My System Specs![]() | |||||||||||||
| | #4 (permalink) | ||||||||||||
| Guest | Re: Redirection and discarding of error objects Thanx to both for quick and detailed answers; the network at its best! "Hans Dingemans" <hans_dingemans@xxxxxx> wrote in message news:%23mxy$u0$HHA.4496@xxxxxx
| ||||||||||||
My System Specs![]() | |||||||||||||
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Folder Redirection Error | John Whites | Vista General | 0 | 08-11-2008 01:43 PM |
| closing, discarding, saving, undo disks, oh my... | michael sorens | Virtual PC | 3 | 07-24-2008 04:07 PM |
| Why version with redirection output run with error? | David Kriz | PowerShell | 1 | 07-04-2008 12:16 PM |
| Error using mandatory roaming profile and Folder Redirection | wasserja | Vista General | 10 | 08-27-2007 05:09 AM |
| Sane error redirection? | kelanslists@gmail.com | PowerShell | 3 | 03-06-2007 04:49 PM |