- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Re: awk, external command and quotes
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-29-2007 02:07 AM
тАО05-29-2007 02:07 AM
Re: awk, external command and quotes
Here are a couple 'one-liners' from my collection:
Initialize any disks that have *never* been initialized:
------
pipe sho dev dg | gawk "BEGIN {print ""$set noon""}; /Online/ {print ""$mou /over=id /noassi"", $1; print ""$if f$mess( $status, \""ident\"") .eqs. \""%NOHOMEBLK\"" -""; print "" then init/sys /limit"", $1, ""UNUSED""}" sys$pipe: | @sys$pipe:
Show the size of all locally mounted disks (in MB):
------
pipe show dev d/mou | GAWK "/Mounted/ && !/(remote mount)/ {print ""$ write sys$output \"""" $1 ""\t\"", f$getdvi( \"""" $1 ""\"", \""maxblock\""), \"" bl.\t\"", f$getdvi( \"""" $1 ""\"", \""maxblock\"")/2048, \"" MB\""""}" sys$pipe: | @sys$pipe:
Note: While I am an HPE Employee, all of my comments (whether noted or not), are my own and are not any official representation of the company
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-29-2007 02:23 AM
тАО05-29-2007 02:23 AM
Re: awk, external command and quotes
I am not sure I understand: I have a variable number of BG devices, say 50, so passing a pid will not help
Sheldon
Thanks a bunch for the procedures, I will have a close look
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-29-2007 02:32 AM
тАО05-29-2007 02:32 AM
Re: awk, external command and quotes
However you could join the pids (e.g. with a comma) if you wanted, and then split them again...
Or of course, put the raw pid details in a file that is read by the awk script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-31-2007 08:00 PM
тАО05-31-2007 08:00 PM
Re: awk, external command and quotes
It defines some symbols
- statbyr
sorts the BG Devices by Bytes received
- statbys
sorts the BG Devices by Bytes sent
- statior
sorts the Bg devices by I/O received
- statios
sorts the Bg devices by I/O sent
It is highly inefficient, as I do
for (bg in prcnam)
if (bg == toupper(dev))
printf ...
So if I have 200 bg devices, I will be 200x200 times in this loop
I have been surprised to discover that without the line
for (bg in prcnam), I do not find any array member.
Some with a higher knowledge of awk may explain it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-31-2007 10:07 PM
тАО05-31-2007 10:07 PM
Re: awk, external command and quotes
1)
What's the tolower doing in "if (/^Device/) {tolower" ?
Did you mean:
if (/^Device/) {split (substr($2,1,(length($2)-2)),x,","); bg=tolower(x[1]) ;}
And is that substr stuff just to get of the ":"?
Then just split on that!
if (/^Device/) {split $2,x,":"); bg=tolower(x[1]) ;}
2)
... dev=toupper($2)
:
for (bg in prcnam)
if (bg == toupper(dev))
Is that second 'toupper' 'just in case the first one did not work?'
I think all you need is: bg = dev .. but at a place where all the other data is collected. I don't have a system with 'ucx shwo dev/full' available right not.
But let's assume 'Bytes transferred' is the last line.
In that case the solution show be:
/Bytes transferred/ {byt = 0 ; byt=$3 ; byr= 0 ; byr=$4 ;
bg = dev;
printf(...)
}
3) Should the printting of the header line (print("device... ) not be part of the BEGIN {} block?
4) Why 'awk' 4 times for 4 sort orders?
The data could change?! awk once, sort 4 times! Append to header lines after each sort.
Cheers,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-31-2007 10:20 PM
тАО05-31-2007 10:20 PM
Re: awk, external command and quotes
>>>Wow, that's just horrible.
Yes, I concur
:-)
>>>1)
What's the tolower doing in "if (/^Device/) {tolower" ?
the bg device in the first list (with the pid) and the second list are one in uppercase and the other in lowercase, so the test failed
>>>And is that substr stuff just to get of the ":"?
yes, because comparing bg227 and bg227: will fail :-)
Then just split on that!
if (/^Device/) {split $2,x,":"); bg=tolower(x[1]) ;}
2)
... dev=toupper($2)
:
for (bg in prcnam)
if (bg == toupper(dev))
>>>Is that second 'toupper' 'just in case the first one did not work?'
I forgot this one.
>>>I think all you need is: bg = dev .. but at a place where all the other data is collected. I don't have a system with 'ucx shwo dev/full' available right not.
But let's assume 'Bytes transferred' is the last line.
Yes it is
In that case the solution show be:
/Bytes transferred/ {byt = 0 ; byt=$3 ; byr= 0 ; byr=$4 ;
bg = dev;
printf(...)
}
3) Should the printting of the header line (print("device... ) not be part of the BEGIN {} block?
May be, but anyway I want it at the back of the display, because I sort with the higher values at the end.
4) Why 'awk' 4 times for 4 sort orders?
The data could change?! awk once, sort 4 times! Append to header lines after each sort.
Yes of course
Thanks for your inputs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-31-2007 10:45 PM
тАО05-31-2007 10:45 PM
Re: awk, external command and quotes
>>>But let's assume 'Bytes transferred' is the last line.
In that case the solution show be:
/Bytes transferred/ {byt = 0 ; byt=$3 ; byr= 0 ; byr=$4 ;
bg = dev;
printf(...)
}
And I no longer have the pid and prcnam.
There is something I have not understood in the flow of data in awk...
:-(
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-31-2007 11:24 PM
тАО05-31-2007 11:24 PM
Re: awk, external command and quotes
Print them out for a debug run, may on 1 device?
Email me a sample SHOW DEV BG/FULL as well as a sample UCX SHOW DEV/FULL and I'll see if I can find time to cehck it.
Flow in AWK is a surprise for first time users.
The main flow is 'all code' for all record in the input.
The /something/ {block} construct is really an 'if ($0 look like something) then {block}'
Most awk programs have simple {} block with no conditional, making that run for every line.
You can add a BEGIN {} and END {} which run jsut once typically to setup, print header fin BEGIN, and to print a total in END.
Cheers,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-31-2007 11:48 PM
тАО05-31-2007 11:48 PM
Re: awk, external command and quotes
I have emailed you the various files.
Thanks for your time.
I am trying to debug.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-13-2007 08:03 PM
тАО06-13-2007 08:03 PM
Re: awk, external command and quotes
It is available at
http://dcl.openvms.org/stories.php?story=07/06/04/4359262