简体   繁体   中英

code to auto detect machines

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM