Re: [Networker] How can I do this in perl?
2004-11-10 18:25:17
> How can I do the equivalent of this shell script in perl?
>
> #!/bin/sh
> /usr/sbin/nsradmin -s server -i <<EOF
> . type: NSR $1; name: $2
> print
> EOF
There are several ways.
#1 most like your shell..
#!/usr/bin/perl
system ("/usr/sbin/nsradmin -s server -i " . <<EOF);
print type: NSR $ARGV[0]; name: $ARGV[1]
EOF
#2
#!/usr/bin/perl
open (ADM, "|/usr/sbin/nsradmin -s server -i") or
die "Couldn't open pipe to nsradmin.\n";
print ADM "type: NSR $ARGV[0]; name: $ARGV[1]\n";
Neither of those solutions capture the output. It just goes to STDOUT
and the screen. Something like...
my @reply = `/usr/sbin/nsradmin -s server -i " . <<EOF`;
print [whatever....]
EOF
would return the data in @reply.
> where I'm just printing out the info to standard output and $1 and $2
> are passed to the script and would be something like 'client' and
> 'client_name', or 'group' and 'group_name', etc. I tried all kinds of
> open commands with pipes, etc. Nothing seems to work.
--
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. >
--
Note: To sign off this list, send a "signoff networker" command via email
to listserv AT listmail.temple DOT edu or visit the list's Web site at
http://listmail.temple.edu/archives/networker.html where you can
also view and post messages to the list. Questions regarding this list
should be sent to stan AT temple DOT edu
=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
|
|
|