Output with horizontal formats


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Output with horizontal formats
# 1  
Old 09-05-2012
Output with horizontal formats

// AIX 5.3 & 6.1

This command
PHP Code:
powermt display dev=all 
returns the output of
HTML Code:
Pseudo name=hdiskpower50
Symmetrix ID=000190101757
Logical device ID=05F0
state=alive; policy=SymmOpt; priority=0; queued-IOs=0
==============================================================================
---------------- Host ---------------   - Stor -   -- I/O Path -  -- Stats ---
###  HW Path                I/O Paths    Interf.   Mode    State  Q-IOs Errors
==============================================================================
   0 fscsi0                    hdisk101  FA  9cA   active  alive      0      0
   1 fscsi4                    hdisk202  FA  8cA   active  alive      0      0

Pseudo name=hdiskpower51
Symmetrix ID=000190101757
Logical device ID=05F1
state=alive; policy=SymmOpt; priority=0; queued-IOs=0
==============================================================================
---------------- Host ---------------   - Stor -   -- I/O Path -  -- Stats ---
###  HW Path                I/O Paths    Interf.   Mode    State  Q-IOs Errors
==============================================================================
   0 fscsi0                    hdisk102  FA  9cA   active  alive      0      0
   1 fscsi4                    hdisk203  FA  8cA   active  alive      0      0

Pseudo name=hdiskpower52
Symmetrix ID=000190101757
Logical device ID=05F5
state=alive; policy=SymmOpt; priority=0; queued-IOs=0
==============================================================================
---------------- Host ---------------   - Stor -   -- I/O Path -  -- Stats ---
###  HW Path                I/O Paths    Interf.   Mode    State  Q-IOs Errors
==============================================================================
   0 fscsi0                    hdisk103  FA  9cA   active  alive      0      0
   1 fscsi4                    hdisk204  FA  8cA   active  alive      0      0
From the output, I hope to get the summary output below:
HTML Code:
name             Symmetrix ID     Device ID   State    I/O Paths   Mode  State
hdiskpower50  000190101757   05F0          alive     hdisk101    active alive
------------------------------------------------- hdisk202    active alive
hdiskpower51  000190101757   05F1          alive     hdisk102    active alive
------------------------------------------------- hdisk203    active alive
.... and so on ...
Please advise.
# 2  
Old 09-06-2012
Save the output of your command into file named "tmp7" and run the below perl code

Code:
#! /bin/perl

open(FH,"< tmp7") || die "couldnt open the file tmp7";
$flag=0;
while(<FH>){
if($_=~/^$/){
if($flag==0){
for($i=0;$i<$#array;$i=$i+2){
printf("%s  ",$array[$i]);
}
printf(" I/O Paths Mode  State");
$flag=1;
print "\n";
}
for($i=1;$i<=$#array;$i=$i+2){
printf("%s ",$array[$i]);
}
$chr=sprintf("-"x55);
printf("%25s \n%s%s",$y,$chr,$x);
print "\n";
$#array=-1;
}
if($_=~/^[A-Z]+/){
chomp($_);
@array=(@array,split(/=/));
}
if($_=~/state=(\S+);/){
@array=(@array,state,"              $1");
}
if($_=~/^\s+/){
@fields=split(/\s+/);
$y=$x;
$x="$fields[3] $fields[6] $fields[7]";
}
}

close(FH);


Last edited by msabhi; 09-06-2012 at 05:29 PM..
This User Gave Thanks to msabhi For This Post:
# 3  
Old 09-10-2012
It works GREAT! Appreciate it!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Python Output Displaying Horizontal

I feel bad for posting so much lately. I've just been working on a project for fun to force myself to learn Python better. Recently I decided to incorporate this ping.py script on github found here. I'm not going to bore you with all the changes I made, but the problem now lies in this function... (8 Replies)
Discussion started by: Azrael
8 Replies

2. Shell Programming and Scripting

Help! output format from vertical to horizontal

Hi All, please help to achieve the desired output Example: I have a file which contains the below data empname robert empid 787 design consultant empname alex empid 898 design advocate Desired output should be empname empid design robert 787 consultant (19 Replies)
Discussion started by: rocky2013
19 Replies

3. Shell Programming and Scripting

How do i do the vertical to horizontal??

51009 8746 8912 17986 20315 24998 5368 38934 7805 8566 (4 Replies)
Discussion started by: nikhil jain
4 Replies

4. UNIX for Dummies Questions & Answers

vertical to horizontal

dear all, i'm new to unix and i try to figure out the best case for making list of vertical text to become horizontal and skip the line 1 and 2. example text : Data DATE XXXXX MAX 47 53 49 51 48 48 7 46 51 8 25 (6 Replies)
Discussion started by: andrisetia
6 Replies

5. Shell Programming and Scripting

Compare two files in different formats and get output

File A: DATAFILE TABLESPACE ------------------------- ------------------------- /dev/rprod_0032_011 D_EEM /dev/rprod_0032_012 D_ESO_REF ... (1 Reply)
Discussion started by: Daniel Gate
1 Replies

6. UNIX for Dummies Questions & Answers

Horizontal to vertical

Hi, Silly question, if I have an excel file that looks something like this: ................. Subject 1 Subject 2 Subject 3 Subject 4 Fever..............13...........9.............23..........14 Headache.........2............12...........18..........23... (3 Replies)
Discussion started by: Xterra
3 Replies

7. Shell Programming and Scripting

Formatting isql output to horizontal format

Hi I am formatting informix isql output(vertical) to horizontal format. Suppose I have the following content in the flat file from isql output - item_nbr 0 usfn_label Subscriber Class usfn_name SBCLASS usfn_value bl5 item_nbr 1 usfn_label Switch Name usfn_name switchName... (2 Replies)
Discussion started by: nsinha
2 Replies

8. UNIX for Dummies Questions & Answers

Help with Date Formats

Hi, Following are the results of various date formats: 1. date +%h" "%d Result: Jun 02 2. date Result: Tue Jun 2 09:59:15 CDT 2009 If i use the date format as date +%h%d then i am getting the date as 02. I want the day to be displayed as "2" instead of "02". so my result should... (1 Reply)
Discussion started by: sandeep_1105
1 Replies

9. UNIX for Dummies Questions & Answers

date formats

Hi, I want to generate file name in the following date format, "YYYYMMDDHHHHMISS" plz. help me how to do that? (6 Replies)
Discussion started by: harshad.katruwa
6 Replies

10. Shell Programming and Scripting

Vi horizontal scrolling

I have to look through logfiles where lines are several hundred characters long and if I open the log in Vi it automatically word wraps the line. In Vim you can use the -nowrap option to stop this, but how can you do this in Vi? I ask because I don't want to see the whole line, just the first few... (8 Replies)
Discussion started by: rupweb
8 Replies
Login or Register to Ask a Question