Is Windows running

C

Chris Arnott

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.
 
S

Sam Holden

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?
 
S

Sandman

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?[/QUOTE]

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?
 
P

Petri

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
 
L

leeg

Sandman said:
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.
[/QUOTE]
Grokking the results of nmap -O (http://www.insecure.org/nmap) may be
useful, in that case.
 
C

Chris

Chris said:
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
 
L

l v

Chris said:
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
 
B

Ben Morrow

l v said:
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
 
L

l v

Ben said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top