in reply to Need Help: Error/die-Handling with Perl & Powershell

I agree with marto, not enough details

Probably just catching stdout/stderr is needed?

see http://stackoverflow.com/questions/8184827/powershell-capture-the-output-from-external-process-that-writes-to-stderr-in-a

alternatively try to see if die() raises an exception ...

see http://stackoverflow.com/questions/20637600/catch-perl-errors-from-powershell-script

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

PS: FWIW, found the links by googling your title!

update

tested, you need to catch STDERR

PS C:\Windows\system32> $cmdOutput = perl -e 'die(1)' 2>&1 PS C:\Windows\system32> echo $cmdOutput perl.exe : 1 at -e line 1. Bei Zeile:1 Zeichen:18 + $cmdOutput = perl <<<< -e 'die(1)' 2>&1 + CategoryInfo : NotSpecified: (1 at -e line 1.:String) [ +], Remot eException + FullyQualifiedErrorId : NativeCommandError

this looks like there are other options to catch RemoteException from within PS, but unfortunately that's OT and not my expertise.

FWIW: I tested a PS try but it didn't catch.

Replies are listed 'Best First'.
Re^2: Need Help: Error/die-Handling with Perl & Powershell ($lastexitcode)
by LanX (Saint) on Dec 15, 2016 at 16:39 UTC