[Console]::Error.WriteLine("Error Text!")
"Mike Miller" <mike@xxxxxx> wrote in message
news:OG5p4NMQIHA.4752@xxxxxx
Quote:
> Shay, Kiron,
>
> Thanks for giving this a try, but the suggestions you made only simulate
> the look of STDERR output in powershell, but is still printed to STDOUT.
>
> If this was a bash script, I would say:
> echo "This is written to STDERR" 1>&2
>
> I had noticed this syntax in some of the PowerShell docs. Interestingly
> PowerShell will redirect STDERR to STDOUT using this syntax, but throws an
> error when trying to use this method to redirect STDOUT to STDERR.
>
> PS>write-error "I'm redirecting STDERR to STDOUT" 2>&1
> write-error "I'm redirecting STDERR to STDOUT" 2>&1 : I'm redirecting
> STDERR to STDOUT
>
> Or from a script:
> PS>& c:\test2.ps1
> C:\test2.ps1 : I'm redirecting STDERR to STDOUT
> At line:1 char:2
> + & <<<< c:\test2.ps1
>
> But when redirecting STDOUT to STDERR:
> PS>write-output "I'm trying to write to STDERR" 1>&2
> The redirection operator '1>&2' is not supported yet.
> At line:1 char:49
> + write-output "I'm trying to write to STDERR" 1>&2 <<<<
>
> I'd welcome any other ideas. For now I'll use write-stderr. It certainly
> isn't unusable for my case, just noisier than necessary.
>
> Mike
>
>
> "Mike Miller" <mike@xxxxxx> wrote in message
> news:OFTqo2pPIHA.484@xxxxxx Quote:
>> I'm looking for a way to write to STDERR. The only method I've found so
>> far is write-error, but PowerShell likes to add "useful" information like
>> script name, arguments, etc. How can this be done?
>>
>> To elaborate, I'm building a hook for subversion which will deny anyone
>> from committing too much data at one time. In order to return an error
>> message to the user, the error needs to be written to STDERR. AFAIK the
>> only way to do this is with write-error.
>>
>> So currently, the user gets an error back like this (hyphens mine):
>> ----------------------------------------------------------------------
>> C:\svn\repos\myrepo\hooks\pre-commit.ps1 :
>> Your commit exceeds the maximum size allowed by this server.
>> At line: 1 char: 39
>> + c:\svn\repos\myrepo\hooks\pre-commit.ps1 <<<< c:\svn\repos\myrepo 3-1
>> ----------------------------------------------------------------------
>>
>> Instead of simply:
>> ----------------------------------------------------------------------
>> Your commit exceeds the maximum size allowed by this server.
>> ----------------------------------------------------------------------
>>
>> I've tried using write-warning, but this doesn't go to STDERR.
>>
>> Mike
>>
>>
>
>