Networker

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

2006-04-27 20:10:12
Subject: Re: [Networker] Can't get nsradmin to work via Perl script
From: George Sinclair <George.Sinclair AT NOAA DOT GOV>
To: NETWORKER AT LISTSERV.TEMPLE DOT EDU
Date: Thu, 27 Apr 2006 20:06:33 -0400
Well, getting rid of the 'waitpid' command fixed its little wagon, and no, I have no idea why I was waiting.

Thanks!!!

George

Darren Dunham wrote:

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;



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>