T.R | Title | User | Personal Name | Date | Lines |
---|
9152.1 | | SSDEVO::ROLLOW | Dr. File System's Home for Wayward Inodes. | Wed Mar 12 1997 23:26 | 10 |
| Input or program?
program | awk 'awk-program'
has always worked for me. Now if you want the program to generate
the awk program, that gets a bit more interesting:
awk '`program`'
this will work up to the maximum length of a command line.
|
9152.2 | | SMURF::FENSTER | Yaacov Fenster - System Engineering, Troubleshooting and other m | Thu Mar 13 1997 06:35 | 5 |
| Or you could (in csh):
((program > /tmp/$$.awk); (awk -f /tmp/$$.awk); (rm -f /tmp/$$.awk)).
This will get around command line limitations. (So it's a hack. This IS
UNIX isn't it ?....)
|
9152.3 | | SANITY::LEMONS | And we thank you for your support. | Thu Mar 13 1997 08:19 | 31 |
| Thanks very much for the suggestions. Here's what I'm trying to do:
# Use NetWorker to print the names of the active
# clone backup pools.
nsradmin << EOF
show name
print type:NSR group; autostart:Enabled; pool type:Backup clone
EOF > awk /name:/ {
# Use awk to extract just the pool names
beginning = index ($0, ":")
str_length = length ($0)
group_name = substr ($0, beginning+2, str_length-beginning-2)
print group_name
}
# For each clone pool, find the list of groups that use that
# clone pool
#nsradmin << EOF
#show name; machine type
#print type:NSR client; group: {$1}
#EOF
#
When I execute it, I get:
# csh -x names
Line overflow.
Thoughts?
Thanks!
tl
|
9152.4 | try this | USMV01::DOUCETTE | Use your judgement | Thu Mar 13 1997 11:17 | 19 |
|
Some suggestions:
< EOF > awk /name:/ {
try a pipe vs redirect
EOF | awk /name:/ {
.
.
}
also add some single quotes
EOF | awk '/name:/ {
.
.
}'
|
9152.5 | | SANITY::LEMONS | And we thank you for your support. | Thu Mar 13 1997 11:51 | 40 |
| Hi
Thanks for the suggestions. Here's what happened:
>>EOF > awk /name:/ {
NetWorker administration program.
Portions Copyright M-) Digital Equipment Corporation 1996. All rights
reserved.
Restricted Rights: Use, duplication, or disclosure by the U.S.
Government is subject to restrictions as set forth in subparagraph
(c)(1)(ii) of DFARS 252.227-7013, or in FAR 52.227-19, or in FAR
52.227-14 Alt. III, as applicable.
Portions of this software are proprietary to and embody the
confidential
technology of Digital Equipment Corporation. Posession, use, or
copying of this software and media is authorized only pursuant to a
valid written license from Digital or an authorized sublicensor.
Use the "help" command for help, "visual" for full-screen mode.
nsradmin> nsradmin> No resources found for query:
autostart: Enabled;
pool type: Backup clone;
type: NSR group;
nsradmin> unknown command: EOF
>>EOF | awk /name:/ {
Same as above
>> EOF | awk '/name:/ {
Same as above
Thanks again. Maybe it's that method of using EOF to bound the
nsradmin command . . .
tl
|
9152.6 | Maybe you have to "quit" | NETRIX::"[email protected]" | Brian Haley | Thu Mar 13 1997 13:36 | 15 |
| Hi,
You don't ever quit (or exit or...) nsradmin. Maybe this would fix your
problem:
nsradmin << EOF
show name
print type:NSR group; autostart:Enabled; pool type:Backup clone
quit
EOF
Quit might not be the right command, but you understand what I'm saying.
-Brian
[Posted by WWW Notes gateway]
|
9152.7 | Commands go together | QUARRY::reeves | Jon Reeves, UNIX compiler group | Thu Mar 13 1997 16:03 | 8 |
| You need to put the commands together. In other words:
nsradmin << EOF | awk
[nsradmin commands]
EOF
It's going to make things *much* clearer if you split out your awk script
into a file and use the -f option.
|
9152.8 | | SANITY::LEMONS | And we thank you for your support. | Thu Mar 13 1997 18:29 | 22 |
| Jon
Right on:
nsradmin << EOF | awk '/name:/ {
beginning = index ($0, ":")
str_length = length ($0)
group_name = substr ($0, beginning+2, str_length-beginning-2)
print group_name
}'
show name
print type:NSR pool; pool type:Backup clone; enabled:Yes
quit
EOF
produces the expected output. And yes, it will be much clearer if I
put the awk commands into a separate file. Seeing the awk commands
before what they are to parse is really putting the cart before the
horse.
Many thanks for the help!
tl
|
9152.9 | | SANITY::LEMONS | And we thank you for your support. | Fri Mar 14 1997 13:26 | 18 |
| Even better than what I had before is this:
#!/bin/ksh
# Use NetWorker to print the names of the active
# clone backup pools.
nsradmin << EOF | awk '/name:/,/;/'
show name
print type:NSR pool; pool type:Backup clone; enabled:Yes
quit
EOF
Now, my next magical act is to put the output of this into an array,
that command in a while or for loop can operate on. Any suggestions on
how to do that? I've been staring at the ksh man page and the awk
section in the manual, but it's, er, kinda light on details.
Thanks very much!
tl
|
9152.10 | This might be a good time to learn perl... | QUARRY::reeves | Jon Reeves, UNIX compiler group | Fri Mar 14 1997 15:23 | 0
|