thunders has asked for the wisdom of the Perl Monks concerning the following question:
I have a program that goes through about 400 WINNT computers looking for the service pack number. I use a third party program, pstools, to find this info connecting though the Shell module.
My problem is with unsuccessful results. The psinfo program return sucessful results in about 4 seconds but if it can't find, or can't connect to a computer it can take more than a minute. This problem makes my program run longer than I would like
Is there any way, with the shell module (or backticks, qx(), etc), to kill a shell escape if it take more than, say 10 seconds?
use Shell; use strict; use Spreadsheet::WriteExcel; my @computers = qw(big list of computers); my $workbook = Spreadsheet::WriteExcel->new("ServicePack.xls"); my $worksheet = $workbook->addworksheet(); my $rowcount = 0; for my $computer(@computers){ $user{'computer'} = $computer; $user{'servicepack'} = get_sp($computer); $worksheet->write($rowcount, 0, $user{'computer'}); $worksheet->write($rowcount, 1, $user{'servicepack'}); $rowcount++; } #Function: get_sp #Arguments: Computer Name #Return Value: Service Pack number sub get_sp{ my $cpu = shift @_; my $info= psinfo('\\\\'. $cpu); my @lines = split("\n",$info); @lines = grep {/(Service Pack:)/i} @lines; s/[\w\s]+:\s+(\d)$/$1/ for @lines; my $servicepack = $lines[0]; return ($servicepack || "unknown"); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Dealing with timeouts using the Shell module
by dmmiller2k (Chaplain) on Jan 03, 2002 at 02:23 UTC | |
|
Re: Dealing with timeouts using the Shell module
by mojotoad (Monsignor) on Jan 03, 2002 at 06:33 UTC | |
|
(tye)Re: Dealing with timeouts using the Shell module
by tye (Sage) on Jan 03, 2002 at 03:11 UTC | |
by thunders (Priest) on Jan 03, 2002 at 04:00 UTC | |
by tye (Sage) on Jan 03, 2002 at 04:42 UTC |