Is Windows running

Discussion in 'Perl Misc' started by Chris Arnott, Feb 13, 2004.

  1. Chris Arnott

    Chris Arnott Guest

    Hello and thanks for any help in advance.

    I've written a perl script which connects to the machines in our domain and
    creates a software installed type report. The problem is some of our users
    have dual boot laptops, win2k/linux, and if the user is in linux the script
    fails.

    So, does anyone know of a good way to determine if Windows is not the
    present operating system on a running machine.

    Thanks,

    Chris Arnott.
     
    Chris Arnott, Feb 13, 2004
    #1
    1. Advertising

  2. Chris Arnott wrote:
    > So, does anyone know of a good way to determine if Windows is not
    > the present operating system on a running machine.


    http://www.perldoc.com/perl5.8.0/pod/perlvar.html#$^O

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
     
    Gunnar Hjalmarsson, Feb 13, 2004
    #2
    1. Advertising

  3. Chris Arnott

    Sam Holden Guest

    On Fri, 13 Feb 2004 10:22:29 -0000,
    Chris Arnott <> wrote:
    > Hello and thanks for any help in advance.
    >
    > I've written a perl script which connects to the machines in our domain and
    > creates a software installed type report. The problem is some of our users
    > have dual boot laptops, win2k/linux, and if the user is in linux the script
    > fails.
    >
    > So, does anyone know of a good way to determine if Windows is not the
    > present operating system on a running machine.


    perldoc -q operating system

    Found in /usr/share/perl/5.8/pod/perlfaq8.pod
    How do I find out which operating system I'm running under?

    Which part of the answer to that FAQ did you not understand?

    --
    Sam Holden
     
    Sam Holden, Feb 13, 2004
    #3
  4. Chris Arnott

    Sandman Guest

    In article <>,
    (Sam Holden) wrote:

    > > I've written a perl script which connects to the machines in our domain and
    > > creates a software installed type report. The problem is some of our users
    > > have dual boot laptops, win2k/linux, and if the user is in linux the script
    > > fails.
    > >
    > > So, does anyone know of a good way to determine if Windows is not the
    > > present operating system on a running machine.

    >
    > perldoc -q operating system
    >
    > Found in /usr/share/perl/5.8/pod/perlfaq8.pod
    > How do I find out which operating system I'm running under?
    >
    > Which part of the answer to that FAQ did you not understand?


    Sarcasm and insults aside, my interpretation of the problem was that he wanted
    to run a script on machine A that connects to machine B, C and D, but only if
    they are running Windows.

    Presumably, he is well aware of what operating system he is using on machine A.


    Chris, is there any common factor to the linux installations? I.e. do all use
    the SSH deamon, so you could beforehand try to connect to port 22, and if you
    get an answer, you'll know they are running Linux.

    Alternatively, if the Windows machines have RDC activated, surely this can be
    checked over the network?

    --
    Sandman[.net]
     
    Sandman, Feb 13, 2004
    #4
  5. Chris Arnott

    Petri Guest

    In article <Gz1Xb.6$8G.55@psinet-eu-nl>, Chris Arnott says...
    > I've written a perl script which connects to the machines in
    > our domain and creates a software installed type report.
    > The problem is some of our users have dual boot laptops,
    > win2k/linux, and if the user is in linux the script fails.


    > So, does anyone know of a good way to determine if Windows is
    > not the present operating system on a running machine.


    One way that's fast (no protocol timeouts), is by checking against a listening
    tcp socket on the various computers.
    You could try by connecting to shared Windows resources like c$, but that would
    have a timeout delay if the host happened to be running Linux (assuming SAMBA
    isn't running and even sharing something with the same name).

    A TCP socket will die instantly* if no one is listening at the socket, since the
    other host will return a TCP RST immediately in that case.
    I hope your computers aren't behind portfiltering firewalls or anything, though.
    :)

    * My Win32 still tries 3 times before giving up, which takes 1 second in total.

    Someone already suggested testing against the ssh port.
    This assumes you are not running an ssh-server on your Windows systems, and that
    you ARE on your Linux systems.

    Here's an example:
    ---8<---
    #!/usr/bin/perl -w
    use strict;
    use warnings;
    use IO::Socket;

    $_ = shift;
    my $s= IO::Socket::INET->new($_ . ':22') ?
    print "'$_' has sshd running (Linux?)\n" :
    print "'$_' does not have sshd running (Win32?)\n";
    ---8<---

    Try it like this:
    test.pl host1

    Hope this helps!

    Petri
     
    Petri, Feb 13, 2004
    #5
  6. Chris Arnott

    leeg Guest

    Sandman wrote:

    > In article <>,
    > (Sam Holden) wrote:
    >
    >> > I've written a perl script which connects to the machines in our domain
    >> > and creates a software installed type report. The problem is some of
    >> > our users have dual boot laptops, win2k/linux, and if the user is in
    >> > linux the script fails.
    >> >
    >> > So, does anyone know of a good way to determine if Windows is not the
    >> > present operating system on a running machine.

    >>
    >>
    >> Which part of the answer to that FAQ did you not understand?

    >
    > Sarcasm and insults aside, my interpretation of the problem was that he
    > wanted to run a script on machine A that connects to machine B, C and D,
    > but only if they are running Windows.
    >

    Grokking the results of nmap -O (http://www.insecure.org/nmap) may be
    useful, in that case.

    --
    I am leeg, for we are many.
    http://users.ox.ac.uk/~wadh1342
     
    leeg, Feb 13, 2004
    #6
  7. Chris Arnott

    Chris Guest

    Chris Arnott wrote:
    > Hello and thanks for any help in advance.
    >
    > I've written a perl script which connects to the machines in our domain and
    > creates a software installed type report. The problem is some of our users
    > have dual boot laptops, win2k/linux, and if the user is in linux the script
    > fails.
    >
    > So, does anyone know of a good way to determine if Windows is not the
    > present operating system on a running machine.
    >


    Querying an IP port on the target machine may be your best way. You
    might try looking at the source code for the *nix util called 'nmap' and
    see if it provides any clues on how it determines machine types based on
    port querying. Even if the remote machine is Linux running Samba, there
    are ports open and running by default as well as responses on a true
    Windows machine that aren't on a Linux machine running Samba. If you
    know your Linux targets AREN'T running Samba, then the job is greatly
    simplified: query the known SMB port(s) and see if you get a response.

    Universal PnP (universal plug 'n pry-open) is one that comes to mind as
    an example if for instance you know your true Windows machines are all
    running XP, etc. (and haven't run Steve Gibson's excellent "unPnP"
    program -- highly recommended if you are forced to run Windows XP at
    all.) Only you know your site well enough to decide, but querying IP
    ports sounds like about the best way to me.

    Windows Messenger Service is another port you can try. I don't think
    that is used in Samba (pre 3.0 anyway). Port 135 I believe. The "spam
    port."

    Chris
    -----
    Chris Olive
    chris -at- --spammers-are-________-- technologEase -dot- com
    http://www.technologEase.com
    (pronounced "technologies")
     
    Chris, Feb 13, 2004
    #7
  8. Chris Arnott

    l v Guest

    Chris Arnott wrote:
    > Hello and thanks for any help in advance.
    >
    > I've written a perl script which connects to the machines in our domain and
    > creates a software installed type report. The problem is some of our users
    > have dual boot laptops, win2k/linux, and if the user is in linux the script
    > fails.
    >
    > So, does anyone know of a good way to determine if Windows is not the
    > present operating system on a running machine.
    >
    > Thanks,
    >
    > Chris Arnott.
    >
    >

    The dos command nbtstat -a remoteIpAddress would identify if windows was
    running.

    Len
     
    l v, Feb 14, 2004
    #8
  9. Chris Arnott

    Ben Morrow Guest

    l v <> wrote:
    > Chris Arnott wrote:
    > > So, does anyone know of a good way to determine if Windows is not the
    > > present operating system on a running machine.

    >
    > The dos command nbtstat -a remoteIpAddress would identify if windows was
    > running.


    Not if the remote machine was a unix box with samba running (not at
    all unlikely in the given situation).

    Ben

    --
    It will be seen that the Erwhonians are a meek and long-suffering people,
    easily led by the nose, and quick to offer up common sense at the shrine of
    logic, when a philosopher convinces them that their institutions are not based
    on the strictest morality. [Samuel Butler, paraphrased]
     
    Ben Morrow, Feb 14, 2004
    #9
  10. Chris Arnott

    l v Guest

    Ben Morrow wrote:

    > l v <> wrote:
    >
    >>Chris Arnott wrote:
    >>
    >>>So, does anyone know of a good way to determine if Windows is not the
    >>>present operating system on a running machine.

    >>
    >>The dos command nbtstat -a remoteIpAddress would identify if windows was
    >>running.

    >
    >
    > Not if the remote machine was a unix box with samba running (not at
    > all unlikely in the given situation).
    >
    > Ben
    >

    Then perhaps srvinfo.exe from the windows 2000 resource kit.

    Len
     
    l v, Feb 14, 2004
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paul Faulstich
    Replies:
    1
    Views:
    1,172
    Amy G
    Jan 10, 2004
  2. Manuel Krummenacher

    Problems with application running on Windows 2003

    Manuel Krummenacher, Oct 20, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    480
    Manuel Krummenacher
    Oct 20, 2003
  3. Softwaremaker
    Replies:
    2
    Views:
    506
    Rajesh.V
    Oct 27, 2003
  4. BLOOD...
    Replies:
    3
    Views:
    4,796
    mrameshchandra
    Jan 19, 2009
  5. Benjamin Rutt
    Replies:
    2
    Views:
    983
    Peter Hansen
    Dec 20, 2005
Loading...

Share This Page