I have the following script. It almost works. I am searching through a file, however when reading the file it seems to skip to every second line. I know its something simple, however have not found anything that works. Below is the code and following it would be what the file looks like. Each server would be on a separate line in the text file. Any ideas? CODE**
#!/usr/bin/perl -s use strict; open (FILEHANDLE, "<servers.txt"); while (<FILEHANDLE>) { my $ServerName = <FILEHANDLE>; $ServerName = substr($ServerName, 0, -1); print "\n"; print "Checking $ServerName..........\n"; my $ServerSpaceC = `cmd.exe /c dir "\\\\\"$ServerName"\\c\$" | find /i + "bytes free"`; my $ServerSpaceD = `cmd.exe /c dir "\\\\\"$ServerName"\\d\$" | find /i + "bytes free"`; print "*********** $ServerName : Space Available *************\n\n"; $ServerSpaceC = substr($ServerSpaceC, 25); $ServerSpaceC = substr($ServerSpaceC, 0, - 11); $ServerSpaceC =~ s/,//gi; $ServerSpaceD = substr($ServerSpaceD, 25); $ServerSpaceD = substr($ServerSpaceD, 0, - 11); $ServerSpaceD =~ s/,//gi; my $availServerSpaceC = $ServerSpaceC / 1024 / 1024 / 1024; my $availServerSpaceD = $ServerSpaceD / 1024 / 1024 / 1024; if ($ServerSpaceC <= 999999999) { $availServerSpaceC = $availServerSpaceC * 1024; print "$ServerName C: Drive: $availServerSpaceC MB Free Space\n"; print " Please clean up D: Drive space on $ServerName\n\n"; } else { print "$ServerName C: Drive: $availServerSpaceC GB Free Space\n"; } if ($ServerSpaceD <= 999999999) { $availServerSpaceD = $availServerSpaceD * 1024; print "$ServerName D: Drive: $availServerSpaceD MB Free Space\n"; print " Please clean up D: Drive space on $ServerName\n\n"; } else { print "$ServerName D: Drive: $availServerSpaceD GB Free Space\n"; } print "\n"; print "************ End $ServerName : Space Report *****************\n +\n"; } close(FILEHANDLE); ****Test File server1234 server2345 server5566
**etc

In reply to Substring problem by keith_kauai

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.