Re: [Networker] Still can't do this in Perl
2004-11-22 14:18:40
>
> I am still unable to perform the equivalent of the following simple
> Bourne shell script in Perl:
>
> #!/bin/sh
> /usr/sbin/nsradmin -s orion -i -<<EOF
> print type: NSR $1; name: $2
> EOF
> I submitted this question prior and received some nice suggestions but
> none of these worked. Here are the things I've tried that do not work:
>
> Option 1:
> #!/usr/bin/perl
> system ("/usr/sbin/nsradmin -s server -i " . <<EOF);
> print type: NSR $ARGV[0]; name: $ARGV[1]
> EOF
Ouch. I think I suggested that without testing. That won't work at
all. There, the command is passed on the command line, not as stdin.
> Option 3:
> #!/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";
>
> Invoked as: same as option 1
>
> Produces following output:
> usage: nsradmin [-c] [-i file] [-s server] [-p prognum] [-v version]
> [query]...
There's no 'print' at the beginning of the command. It should be..
print ADM "print type: NS......
That's just a typo in the nsradmin command, not in the structure of what
you're doing.
> Option 4:
> !/usr/bin/perl
> @reply = `/usr/sbin/nsradmin -s orion -i <<EOF`;
> print type: NSR $ARGV[0]; name: $ARGV[1]
> EOF
>
> Invoked as: same as option 1
>
> Produces following output:
> syntax error at ./c.pl line 3, near "type:"
That won't do any better than 1/2, because again, the commands are
coming in to nsradmin on the command line instead of via STDIN.
--
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
=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
|
|
|