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 - Powershell, Process and StandardError

Reply
 
Old 08-15-2007   #1 (permalink)
Galin Iliev[Galcho]


 
 

Powershell, Process and StandardError

Hi guys,
I have a funny situation here and I hope you might help me.
We've written general purpose tool that executes PS scripts using
System.Diagnostics.Process class and based if there is somethign in
Process.StandardError decides if the script was executed successfuly.

So far so good... we have also PS script that performs Oracle backup using
it's external exp command and this is where is the problem. It seems exp
writes output in StandardOutput AND in StandardError streams. I tried to
redirect output to file but it redirects only StandardOutput text and Error
text stays...
thus we get always failure detected in our code...

Is trere a way to clear Process.StandardError within PS script?

Do you have any suggestions?

Thanks in advance
Galin Iliev [MCT, MCDP]

My System SpecsSystem Spec
Old 08-15-2007   #2 (permalink)
Brandon Shell


 
 

Re: Powershell, Process and StandardError

Did you try redirecting StdErr to StrOut 2>&1
You can also try $error.clear() at the end of you script to see if that
helps.

"Galin Iliev[Galcho]" <Galin Iliev[Galcho]@discussions.microsoft.com> wrote
in message news:37405B38-0BBD-479B-BDDC-6F0EBB9F5CA0@microsoft.com...
> Hi guys,
> I have a funny situation here and I hope you might help me.
> We've written general purpose tool that executes PS scripts using
> System.Diagnostics.Process class and based if there is somethign in
> Process.StandardError decides if the script was executed successfuly.
>
> So far so good... we have also PS script that performs Oracle backup using
> it's external exp command and this is where is the problem. It seems exp
> writes output in StandardOutput AND in StandardError streams. I tried to
> redirect output to file but it redirects only StandardOutput text and
> Error
> text stays...
> thus we get always failure detected in our code...
>
> Is trere a way to clear Process.StandardError within PS script?
>
> Do you have any suggestions?
>
> Thanks in advance
> Galin Iliev [MCT, MCDP]


My System SpecsSystem Spec
Old 08-15-2007   #3 (permalink)
Galin Iliev[Galcho]


 
 

Re: Powershell, Process and StandardError

Thank you Brandon!
This is what I looked for

Many Thanks

Galin Ilieb

"Brandon Shell" wrote:

> Did you try redirecting StdErr to StrOut 2>&1
> You can also try $error.clear() at the end of you script to see if that
> helps.
>
> "Galin Iliev[Galcho]" <Galin Iliev[Galcho]@discussions.microsoft.com> wrote
> in message news:37405B38-0BBD-479B-BDDC-6F0EBB9F5CA0@microsoft.com...
> > Hi guys,
> > I have a funny situation here and I hope you might help me.
> > We've written general purpose tool that executes PS scripts using
> > System.Diagnostics.Process class and based if there is somethign in
> > Process.StandardError decides if the script was executed successfuly.
> >
> > So far so good... we have also PS script that performs Oracle backup using
> > it's external exp command and this is where is the problem. It seems exp
> > writes output in StandardOutput AND in StandardError streams. I tried to
> > redirect output to file but it redirects only StandardOutput text and
> > Error
> > text stays...
> > thus we get always failure detected in our code...
> >
> > Is trere a way to clear Process.StandardError within PS script?
> >
> > Do you have any suggestions?
> >
> > Thanks in advance
> > Galin Iliev [MCT, MCDP]

>
>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
is there a way to process large files in powershell? PowerShell
Re: How to check for Powershell process PowerShell
pipe to non-powershell process PowerShell
Powershell Execute process PowerShell
the powershell.exe process is grow PowerShell


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