Getting PERL to return info from an external 'command'

Discussion in 'Perl Misc' started by Ralph, Aug 8, 2003.

  1. Ralph

    Ralph Guest

    Hi, I have a particular task I need perl to accomplish, but I'm not
    sure how to do it, or what the code involved would be...

    Given a list (end-of-line separated) of server names (NetBIOS), I need
    PERL to run through the file, and do an NSLOOKUP $_ on the server
    name. The return looks like this:

    Server: blah.blah.blah.com
    Address: 1.2.3.4

    Name: ServerIWant.company.com
    Address: 4.3.2.1

    I want to be able to extract the ServerIWant.company.com from the
    output of the DOS command, and stick it into a variable which I can
    then write to a text file, essentially replacing the NetBIOS names
    with DNS names...to make it simple.

    Can anyone give me a quick example, or help throw some code together?

    ../Ralph
     
    Ralph, Aug 8, 2003
    #1
    1. Advertising

  2. Ralph wrote:
    > Hi, I have a particular task I need perl to accomplish, but I'm not
    > sure how to do it, or what the code involved would be...
    >
    > Given a list (end-of-line separated) of server names (NetBIOS), I
    > need PERL to run through the file, and do an NSLOOKUP $_ on the
    > server name. The return looks like this:
    >
    > Server: blah.blah.blah.com
    > Address: 1.2.3.4
    >
    > Name: ServerIWant.company.com
    > Address: 4.3.2.1
    >
    > I want to be able to extract the ServerIWant.company.com from the
    > output of the DOS command, and stick it into a variable which I can
    > then write to a text file, essentially replacing the NetBIOS names
    > with DNS names...to make it simple.


    Do you really need help with _all_ the steps involved? In that case,
    you'd better start by learning some basic Perl coding:

    http://learn.perl.org/

    Then you should at least do _something_ by yourself, and come back
    here only after that, provided that you get stuck with a particular
    detail.

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
     
    Gunnar Hjalmarsson, Aug 8, 2003
    #2
    1. Advertising

  3. pete <> wrote:


    > open (IN, "< filename");



    You should always, yes *always*, check the return value from open():

    open (IN, "< filename") or die "could not open 'filename' $!";


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Aug 9, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ferenc Engard
    Replies:
    2
    Views:
    150
  2. Marc Heiler

    Getting PID of external command

    Marc Heiler, Mar 12, 2007, in forum: Ruby
    Replies:
    3
    Views:
    136
    Jan Friedrich
    Mar 17, 2007
  3. Replies:
    2
    Views:
    162
    Tad McClellan
    Mar 26, 2005
  4. alfonsobaldaserra
    Replies:
    4
    Views:
    198
    alfonsobaldaserra
    Jul 22, 2009
  5. ccc31807

    Perl script running external command

    ccc31807, Mar 23, 2011, in forum: Perl Misc
    Replies:
    3
    Views:
    178
    ccc31807
    Mar 24, 2011
Loading...

Share This Page