I'm trying to learn perl because I found some great scripts that I can use on the job, but I'm having trouble customizing the scripts, your help will be appreciated much. The Original code will take two line parameters and returns the information for one NT server service and it works fine for one server, but I want it to return information for several servers so I changed the code to read a file that has a list of servers and service I want information on. This is part of the original code that returns infromation for one server:
$DisplayName = shift @ARGV || die; $Machine = Win32::NodeName() unless( $Machine = shift @ARGV ); $Machine = "\\\\$Machine"; $Machine =~ s/^\\{2,}/\\\\/; if( Win32::Service::GetServices( $Machine, \%List ) )
This works fine for one server. I want it to read a file with a list of servers and I changed the code, but of course it doesn't work I get an error: Could not connect to \\650SAN: The RPC server is unavailable. I changed the code to the following from the code above. This reads the file okay, but I get the error: "Could not connect to \\650SAN: The RPC server is unavailable". for each line it reads from the file.
while ($Line = <>) { chomp($Line); $Line =~ s/^[ \t]+//; ### Check for spaces and tabs and remove $Line =~ s/[ \t]+$//; ### Check for trailing spaces and tabs and r +emove $Line =~ s/[ \t]+/ /g; ### Global Substitution to remove extra spac +es and ### tabs between words @ARGV = split(/ \\\\/, $Line); $DisplayName = shift @ARGV || die; $Machine = Win32::NodeName() unless( $Machine = shift @ARGV ); $Machine = "\\\\$Machine"; $Machine =~ s/^\\{2,}/\\\\/; if( Win32::Service::GetServices( $Machine, \%List ) )

In reply to Read a config file by Anonymous Monk

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.