i need to write a program that auto detects windows and unix machines in C# on a network then copy a folder from a windows shared directory to the remote machine and gather how many processors are on the machine. I don't know of any C# functions that would help with detecting machines and their ips. I don't have access to active directory or have a central server for all the machines. I can create a perl program to run on the client machines. (also I'm not sure how to access windows shares on a unix machines) general guidance and code examples would be appreciated thanks
-
This is probably what you're looking for http://stackoverflow.com/questions/5116977/c-sharp-how-to-check-the-os-version-at-runtime-e-g-windows-or-linux-without-usi – MilkyWayJoe Apr 10 '12 at 21:25
-
@MilkyWayJoe that would require installing the mono framework on the machines which wouldn't make my boss happy...its not quite what i'm looking for thanks anyways :) – Apr 10 '12 at 21:38
2 Answers
You have two very different questions.
1. Detect if a machine is a Windows or unix machine.
$^O
will give you that in Perl.
$ perl -E'say $^O'
linux
>perl -E"say $^O"
MSWin32
2. Access a remote Windows file share from a unix machine.
Well, it's a SMB file share, for starters.
So all you really need is an SMB client. I quickly found Filesys::SmbClient, a Perl module that seems to fit the bill.

- 367,544
- 15
- 269
- 518
You can use Nmap in order to discover network machines, it is client-less and with the -O parameter it will tell you if the machine is running a Windows OS or a Linux one. You can then use SNMP or WMI to retrieve the number of CPUs even though that requires machines to have SNMP or WMI installed. However with a client running on the remote machine everything would be much easier, expecially if you have to copy files.

- 3,071
- 8
- 44
- 66
-
thanks for the nmap suggestion...i only had one class in networks and we didnt cover that aspect..your right about needing a client to setup sharing and copying – Apr 11 '12 at 14:39