$exec_shell='TASKKILL /F /IM putty* /T 2>nul';
my $a = run_shell($exec_shell);
#i use this function:
sub run_shell {
my ($cmd) = @_;
use IPC::Open3 'open3';
use Carp;
use English qw(-no_match_vars);
my @args = ();
my $EMPTY = q{};
my $ret = undef;
my ( $HIS_IN, $HIS_OUT, $HIS_ERR ) = ( $EMPTY, $EMPTY, $EMPTY );
my $childpid = open3( $HIS_IN, $HIS_OUT, $HIS_ERR, $cmd, @args );
$ret = print {$HIS_IN} "stuff\n";
close $HIS_IN or croak "unable to close: $HIS_IN $ERRNO";
; # Give end of file to kid.
if ($HIS_OUT) {
my @outlines = <$HIS_OUT>; # Read till EOF.
$ret = print " STDOUT:\n", @outlines, "\n";
}
if ($HIS_ERR) {
my @errlines = <$HIS_ERR>; # XXX: block potential if massive
$ret = print " STDERR:\n", @errlines, "\n";
}
close $HIS_OUT or croak "unable to close: $HIS_OUT $ERRNO";
#close $HIS_ERR or croak "unable to close: $HIS_ERR $ERRNO";#bad..todo
waitpid $childpid, 0;
if ($CHILD_ERROR) {
$ret = print "That child exited with wait status of $CHILD_ERROR\n";
}
return 1;
}