Getting PERL to return info from an external 'command'

R

Ralph

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
 
G

Gunnar Hjalmarsson

Ralph said:
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.
 
T

Tad McClellan

open (IN, "< filename");


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

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

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top