How to discover the machine type?
You can try the following Perl one-liner:
perl -MConfig -e 'print "$Config{myarchname}\n";'
I know on Mac OS X Leopard with Perl 5.10.0 it prints "i386-darwin". I don't know of a way in Perl to get the actual processor name - your best bet is probably C since it's a fairly limited set of possibilities. You can get at a C compiler's predefined macros from Perl:
perl -MConfig -e 'print join("\n", split(/ /, $Config{cppsymbols})), "\n";'
This will list C macros like __LITTLE_ENDIAN__
and __MACH__
for Mach-O format and __i386__
(on Leopard at least), as well as the useless ones like __GNUC__
and __STDC__
. Of course, all of this help assumes you have Perl on all machines. If not, I'm sure other languages have similar facilities to help you.
I would suggest you look at the facter component of the Puppet system. From the URL http://reductivelabs.com/projects/facter/.
A cross-platform Ruby library for retrieving facts from operating systems. Supports multiple resolution mechanisms, any of which can be restricted to working only on certain operating systems or environments. Facter is especially useful for retrieving things like operating system names, IP addresses, MAC addresses, and SSH keys.