in reply to Using Perl to detect RAM amount
This script does the job on Win32.
#! perl -slw use Win32::API::Prototype; my $memoryStatus = AllocMemory( 32 ); ApiLink( 'Kernel32', 'GlobalMemoryStatus', 'P', 'V' ); GlobalMemoryStatus( $memoryStatus ); my @keys = qw[ length PercentageLoad TotalPhysical AvailablePhysical TotalPaged AvailablePaged TotalVirtualMemory AvailableVirtualMemory ]; my %mStatus; @mStatus{ @keys } = unpack 'V8', $memoryStatus; printf '%30s : %.2f' . $/, $_, $mStatus{ $_ } / 2**20 for @keys[1 .. $#keys ]; __END__ P:\test>gmem PercentageLoad : 0.00 TotalPhysical : 223.24 AvailablePhysical : 54.38 TotalPaged : 408.66 AvailablePaged : 228.52 TotalVirtualMemory : 2047.88 AvailableVirtualMemory : 2019.03
The TotalPhysical is the one you need. There have been several threads on doing this on various flavours of *nix.
With respect to putting the two on a floppy disc, you might get away with miniperl.exe (5.6.2 ~= 700k) from the source distribution. You would have to copy a few dependancies Config, Dynaloader, Autoloader, Win32::API::Prototype etc. including their binary components. The list isn't huge, however, that doesn't solve the dual boot problem.
But, given that the physical memory doesn't vary from OS to OS (unless you have RAM disks and stuff configured), you would probably be better off booting from a DOS floppy (assuming the hardware can run that) and use the DOS mem command (though that gives a weird mixture of real mode and protect mode numbers).
Or maybe a freeware DOS utility from somewhere. There used to be loads of things like that kicking around. It wouldn't work on non-DOSable hardware, but not much will.
Come to that, if you can boot into the bios configuration, the information ought to be available there.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Using Perl to detect RAM amount
by Tommy (Chaplain) on Jan 06, 2004 at 02:54 UTC | |
by helgi (Hermit) on Jan 06, 2004 at 11:38 UTC | |
|
Re: Re: Using Perl to detect RAM amount
by tachyon (Chancellor) on Jan 06, 2004 at 13:57 UTC |