in reply to Convert from c# to Perl


I'm curious - Why not?

Replies are listed 'Best First'.
Re^2: Convert from c# to Perl
by alwaysuseperl (Novice) on Aug 10, 2010 at 17:44 UTC

    Because when you pipe commands through psexec, you cant parse through it. It throws it in a different format. Ive tried it a few times. for example..

    $var = `psexec \\server netstat -n`;

    shouldn't display what psexec does unless you print $var, but it does

    Thanks for the code! I was close, but never would have figured out the BYREF Variant values.

    Is there a way to display the output of this command?

      You're most likely referring to psexec's STDERR. Try capturing it:
      my $stderr; my $stdout = do { open(local *STDERR, ">", \$stderr) or die "Could not capture STDERR: $!"; qx(psexec \\\\server netstat -n); }; print "psexec stdout: $stdout\n"; print "-" x 60, "\n"; print "psexec stderr: $stderr\n";

        Thanks for the code! I was close, but never would have figured out the BYREF Variant values.

      It was eyepopslikeamosquito, not me :-)

        Yeah, I was trying to get it to stop displaying the intro/header of psexec

        PsExec v1.96 - Execute processes remotely Copyright (C) 2001-2009 Mark Russinovich Sysinternals - www.sysinternals.com netstat exited on webd15 with error code 0.

        I tried that, but it always has the header..

        PsExec v1.96 - Execute processes remotely Copyright (C) 2001-2009 Mark Russinovich Sysinternals - www.sysinternals.com