Networker

Re: [Networker] Can't get nsradmin to work via Perl script

2006-04-27 19:42:45
Subject: Re: [Networker] Can't get nsradmin to work via Perl script
From: Darren Dunham <ddunham AT TAOS DOT COM>
To: NETWORKER AT LISTSERV.TEMPLE DOT EDU
Date: Thu, 27 Apr 2006 16:39:46 -0700
> print WTRFH ". type:NSR client\n";
> print WTRFH "print\n";
> 
> It still only works if I specify the attribute on the show command fist. This 
> makes no sense as it works fine within nsradmin. Also, it works if I create a 
> temp file with the following:
> 
> print type:NSR client
> 
> and then I run nsradmin -s server -i temp_file
> 
> Isn't my script doing the same thing????
> 
> Any ideas?

Not too many.  Your script worked just fine without modifications
(except the server name) on my test server.

But...

> 
> #!/free/bin/perl
> 
> my $program = "nsradmin";
> 
> @args = ("-s", "orion", "-i", "-");
> 
> use IPC::Open2;
> my $pid = open2(\*RDRFH, \*WTRFH, "$program", @args) or die "can't open pipe 
> to $program: $!";
> 
> # Send commands to nsradmin.
> #    print WTRFH "show name\n";
>     print WTRFH "print type:NSR client\n";
>     close (WTRFH);
> 
> waitpid($pid, 0);

Why are you waiting on a process that you're not done interacting with?
For this short of a program, you probably shouldn't wait on it at all.
While I'd expect problems with a longer program, I wouldn't think that
what you're doing would be affected.  Still I'd get rid of that line.

> # get the results.
> my @output = <RDRFH>;
> 
> print @output;


-- 
Darren Dunham                                           ddunham AT taos DOT com
Senior Technical Consultant         TAOS            http://www.taos.com/
Got some Dr Pepper?                           San Francisco, CA bay area
         < This line left intentionally blank to confuse you. >

To sign off this list, send email to listserv AT listserv.temple DOT edu and 
type "signoff networker" in the
body of the email. Please write to networker-request AT listserv.temple DOT edu 
if you have any problems
wit this list. You can access the archives at 
http://listserv.temple.edu/archives/networker.html or
via RSS at http://listserv.temple.edu/cgi-bin/wa?RSS&L=NETWORKER

<Prev in Thread] Current Thread [Next in Thread>