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.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
Hooray!


In reply to Re: Using Perl to detect RAM amount by BrowserUk
in thread Using Perl to detect RAM amount by Tommy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.