Thanks for all your help. In fact your posts helped to go forward with the below code; system ($stop) is trying to stop the smc service and in case the remote system doesn't respond within 30 seconds the script will come out from it and system ($kill) will kill the psexec process in the remote machine and hence the pipe is ended. pskill is a similar sysinternal utility to kill a process remotely
$SIG{ALRM} = \&timed_out;
eval {
alarm (30);
system ($stop);
alarm(0);
};
if ($@ =~ /GOT TIRED OF WAITING/) {
my $kill='pskill' . " " . '\\\\' . $machine . " " . "psexesvc
+";
system ($kill);
sub timed_out {
die "GOT TIRED OF WAITING";
}
|