in reply to Dealing with timeouts using the Shell module

I don't know how much work "psinfo" does, but at least for recent service packs, I think simply checking HKEY_LOCAL_MACHINE/Software/Microsoft/Windows NT/CurrentVersion//CSDVersion in the registry is enough. And Win32::TieRegistry makes checking this on a remote computer rather easy.

I recall Windows often taking a while to decide that the connection to a remote computer was going to fail, but I think that had more to do with my strange setup and some simple testing right now shows it taking only about 4 seconds to fail for me. So, if failures usually happen that fast, then something fairly simple will work:

use Win32::TieRegistry( Delimiter=>"/" ); sub get_sp { my $cpu= shift @_; my $ver= $Registry->{"//$cpu/LMachine/Software/" . "Microsoft/Windows NT/CurrentVersion//CSDVersion"}; if( ! $ver || $ver !~ /(\d+)/ ) { return "unknown"; } return $1; }

        - tye (but my friends call me "Tye")

Replies are listed 'Best First'.
Re: (tye)Re: Dealing with timeouts using the Shell module
by thunders (Priest) on Jan 03, 2002 at 04:00 UTC
    tye,
    Adapting that subroutine and the TieRegistry module greatly speeds up all the successful calls. Unfortunately the failures hang for just as long, and those failures are the real bottleneck. Thanks for an intro to a new module for me to play with regardless. BTW, Pstools,which I originally used for this project, is a pretty useful collection of free command-line Administrative software for those of us who are slumming it with WinNT. I recommend it.

      You can use Net::Ping to more quickly decide that a machine is not available before trying to connect.

      Beyond that, you'll need (because the operating system does not provide an asynchronous method for connecting to these resources) separate threads or separate processes, which, when using Perl, means you need separate processes. And since fork emulation for Win32 Perl still sucks, I think the best choice is currently Win32::Process.

      I'd throw together a quick example of how to do this but I don't have the time at the moment and, unfortunately, I don't think there is a really simple way to do this. The simplest-to-code way is probably to blindly create a new process for each machine and have each append to an output file and then read the results from there after all of the children finish. For a large list of computers, that probably won't work, however.

      I think you could find a module to manage a group of slave processes for you, and that might be a good way to go. Sorry, I can find one quickly at the moment.

              - tye (but my friends call me "Tye")