Hi Guys

I have this simple code below, all it does is,
1- Gets the shared areas of a remote machine.
2- Obtains the top level folder of that share and the drive letter where the share resides.
3- Finally it obtains the size of that top level folder.

However, the script never completes its execution, it through up a message out of memory

Does any of you holly ones knows how can I get this script to work?.....

Many Thanks and sorry for the style of my coding.
use strict; use Win32::Lanman; use File::Spec qw (splitdir); my $input = shift @ARGV; push (my @SrvLst, $input); for my $Srv (@SrvLst) { &Get_Shr($Srv); print "___________________________________________\n"; } sub Get_Shr { my $Machine = shift @_; my $UncSrvName = "\\\\" . $Machine; print "\nAttempting to access '$UncSrvName'\n"; if (Win32::Lanman::NetShareEnum( $UncSrvName , \ my @EnumLst)) { my %SeenPath=(); for my $Share (@EnumLst ) { next if ( ($Share->{path}) =~ /^c/i); next if ( ($Share->{netname})=~ /ipc\$|rpc\$|netlogon\$|ad +min\$|^CDROM|^\w\$/i); my @SplitDir = File::Spec->splitdir(uc ($Share->{path})); my $DrvLttr = @SplitDir[0]; my $TopDir = @SplitDir[1]; my $DrvTop = $DrvLttr . "\\" . $TopDir; unless ( ($SeenPath{($DrvTop)})) { $SeenPath{$DrvTop}=1; print "\nDrvTop=> $DrvTop "; $DrvLttr =~ s/:/\$/; my $TargetPath = $UncSrvName . "\\". $DrvLttr ."\\" . + $TopDir; print "\tSizing "; if (opendir ( DIR, "$TargetPath")) { print "$TargetPath"; my ($Size)=( (qx{dir /s "$TargetPath"})[-2]=~ /([\ +d,]+) bytes/ ); print " : $Size\n"; undef $Size; } else { warn " \n(Access Error : $^E)\n"; } } } } else { print Win32::FormatMessage(Win32::Lanman::GetLastError()) . " +$Machine\n"; } }

In reply to Out of memory. by blackadder

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.