Disk report generation problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Disk report generation problem
# 8  
Old 12-14-2011
Quote:
Originally Posted by ahamed101
See if you have gawk installed...
or try this...
Code:
while read line
do
  arr=( $(echo $line | awk '{print $5, $6, $10}') )
  val=$(grep "${arr[0]} ${arr[1]}" power.txt | awk '{print $NF}')
  test ! -z $val && echo ${arr[2]} $val
done < asm.txt

--ahamed
Ahamed,
gawk is not installed in my AIX machine, also i have tried your code line by line seems "$val" is not coming up. Pls find the output

HTML Code:
cat asm.txt | while read line
> do
>       arr=$(echo $line | awk '{print $5, $6, $10}')
>       echo $arr
>       val=$(grep "${arr[0]} ${arr[1]}" power.txt | awk '{print $NF}')
>       echo $val
> done
34, 3 /dev/asm_disk1
34, 4 /dev/asm_disk2
34, 5 /dev/asm_disk3
34, 11 /dev/asm_spfile
 
Regards
Kamal
# 9  
Old 12-14-2011
Paste the output bash -x script
Please execute the code which I have given, not the one modified.

arr is supposed to be an array and that is why it is given as arr=( ... )

Why do you want to do a cat file | while... ?? when you can do while...done < file?
It qualifies for UUoC!!!


--ahamed

Last edited by ahamed101; 12-14-2011 at 12:32 AM..
# 10  
Old 12-14-2011
Amamed,
Please find the debug output

HTML Code:
$ sh -x script.sh
 
+ 0< asm.txt
+ read line
+ + echo crw-r--r-- 1 oracle dba 34, 3 Jun 21 20:06 /dev/asm_disk1
+ awk {print $5, $6, $10}
arr=34, 3 /dev/asm_disk1
+ + grep 34, 3 /dev/asm_disk1  power.txt
+ awk {print $NF}
val=
+ test ! -z
+ read line
+ + echo crw-r--r-- 1 oracle dba 34, 4 Jun 21 20:06 /dev/asm_disk2
+ awk {print $5, $6, $10}
arr=34, 4 /dev/asm_disk2
+ + awk {print $NF}
+ grep 34, 4 /dev/asm_disk2  power.txt
val=
+ test ! -z
+ read line
+ + awk {print $5, $6, $10}
+ echo crw-r--r-- 1 oracle dba 34, 5 Jun 21 20:06 /dev/asm_disk3
arr=34, 5 /dev/asm_disk3
+ + awk {print $NF}
+ grep 34, 5 /dev/asm_disk3  power.txt
val=
+ test ! -z
+ read line
+ + awk {print $5, $6, $10}
+ echo crw-r--r-- 1 oracle dba 34, 11 Jun 21 20:05 /dev/asm_spfile
arr=34, 11 /dev/asm_spfile
+ + awk {print $NF}
+ grep 34, 11 /dev/asm_spfile  power.txt
val=
+ test ! -z
+ read line
Regards
Kamal
# 11  
Old 12-14-2011
It is working for me... may be there is some issue with () in AIX
Try this...
Code:
while read line
do
  val1=$(echo $line | awk '{print $5}')
  val2=$(echo $line | awk '{print $6}')
  val3=$(echo $line | awk '{print $10}')
  val4=$(grep "$val1 $val2" power.txt | awk '{print $NF}')
  test ! -z $val4 && echo "$val3 $val4"
done < asm.txt

--ahamed

---------- Post updated at 08:49 PM ---------- Previous update was at 08:47 PM ----------

Try this also...
Code:
awk 'NR==FNR{x[$5$6]=$NF;next} x[$5$6]{print x[$5$6],$NF} ' asm.txt power.txt

--ahamed

---------- Post updated at 08:51 PM ---------- Previous update was at 08:49 PM ----------

Code:
while read line
do
  val1=$(echo $line | awk '{print $5,$6}')
  val2=$(echo $line | awk '{print $10}')
  val3=$(grep "$val1" power.txt | awk '{print $NF}')
  test ! -z $val3 && echo $val3 $val2
done < asm.txt

--ahamed
This User Gave Thanks to ahamed101 For This Post:
# 12  
Old 12-14-2011
ahamed,

Below command is perfectly working !! Thanks a lot Smilie

HTML Code:
    awk 'NR==FNR{x[$5$6]=$NF;next} x[$5$6]{print x[$5$6],$NF}' asm.txt power.txt
somehow the rest of the codes are not working properly only the final line is grepped

HTML Code:
+ 0< asm.txt
+ read line
+ + echo crw-r--r-- 1 oracle dba 34, 3 Jun 21 20:06 /dev/asm_disk1
+ awk {print $5}
val1=34,
+ + echo crw-r--r-- 1 oracle dba 34, 3 Jun 21 20:06 /dev/asm_disk1
+ awk {print $6}
val2=3
+ + echo crw-r--r-- 1 oracle dba 34, 3 Jun 21 20:06 /dev/asm_disk1
+ awk {print $10}
val3=/dev/asm_disk1
+ + awk {print $NF}
+ grep 34, 3 power.txt
val4=
+ test ! -z
+ read line
+ + awk {print $5}
+ echo crw-r--r-- 1 oracle dba 34, 4 Jun 21 20:06 /dev/asm_disk2
val1=34,
+ + awk {print $6}
+ echo crw-r--r-- 1 oracle dba 34, 4 Jun 21 20:06 /dev/asm_disk2
val2=4
+ + awk {print $10}
+ echo crw-r--r-- 1 oracle dba 34, 4 Jun 21 20:06 /dev/asm_disk2
val3=/dev/asm_disk2
+ + awk {print $NF}
+ grep 34, 4 power.txt
val4=
+ test ! -z
+ read line
+ + awk {print $5}
+ echo crw-r--r-- 1 oracle dba 34, 5 Jun 21 20:06 /dev/asm_disk3
val1=34,
+ + awk {print $6}
+ echo crw-r--r-- 1 oracle dba 34, 5 Jun 21 20:06 /dev/asm_disk3
val2=5
+ + awk {print $10}
+ echo crw-r--r-- 1 oracle dba 34, 5 Jun 21 20:06 /dev/asm_disk3
val3=/dev/asm_disk3
+ + awk {print $NF}
+ grep 34, 5 power.txt
val4=
+ test ! -z
+ read line
+ + echo crw-r--r-- 1 oracle dba 34, 11 Jun 21 20:05 /dev/asm_spfile
+ awk {print $5}
val1=34,
+ + echo crw-r--r-- 1 oracle dba 34, 11 Jun 21 20:05 /dev/asm_spfile
+ awk {print $6}
val2=11
+ + echo crw-r--r-- 1 oracle dba 34, 11 Jun 21 20:05 /dev/asm_spfile
+ awk {print $10}
val3=/dev/asm_spfile
+ + grep 34, 11 power.txt
+ awk {print $NF}
val4=/dev/hdiskpower11
+ test ! -z /dev/hdiskpower11
+ echo /dev/asm_spfile /dev/hdiskpower11
/dev/asm_spfile /dev/hdiskpower11
+ read line
thanks again for your help

Regards
Kamal
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Report generation using script

Hi all I have a unix script that generates a report with the following information: uptime, mounted file systems, disk usage (> 90% --> critical, <75%-90%> --> warning, < 75% healthy), Mem usage, CPU usage and load average. But I would like to create one single report containing all this... (5 Replies)
Discussion started by: fretagi
5 Replies

2. UNIX for Beginners Questions & Answers

UNIX cluster disk usage report generation for yesterday & today and email

HI Team, I am trying to create a shell script to generate a yesterday and today report to compare and email in daily basis. can you please help me on the same. #!/bin/bash #Author: ******************* #Description: This script will return the following set of system information: ... (2 Replies)
Discussion started by: Mi4304
2 Replies

3. Shell Programming and Scripting

Report generation using perl script

Hi, I have a perl script to read the log file and create a report from it. I have the script file and log file in a different directories. Now i have pipe the log file data to the perl script to create the report (HMTL file). I am using the below command this isn't working tail -f... (4 Replies)
Discussion started by: vel4ever
4 Replies

4. Shell Programming and Scripting

Report generation based on certain conditions

Hi I recently joined a project where I have been asked to generate a report using shell script accessing UNIX box. I have no idea on how to do it as I am a beginner and learning shell scripts. Suppose I have a XML: Code: ... (3 Replies)
Discussion started by: vat1kor
3 Replies

5. Shell Programming and Scripting

File Report Generation

hi all i need to generate a report file that contains the following details of files present in a directory. 1. File name 2.Complete path for each files and directory 3.File size 4.Days older example i have a directory testing that contains sub-directories and some files. i need to make a... (5 Replies)
Discussion started by: yashwantkumar
5 Replies

6. Shell Programming and Scripting

Report Generation with Grep

All, I am pretty new to Unix Environment. I am not sure if my requirement can be accomplished in Unix. I did try searching this forum and others but could not get an answer. Requirement is explained below: I have a set of files in a folder. file1_unload file2_unload file3_unload... (7 Replies)
Discussion started by: bharath.gct
7 Replies

7. Shell Programming and Scripting

Report generation

Hello, I got a requirement in writing a KSH script in unix, please help me out the requirement is there are two folders Folder1 and Folder2 and there are same files in the different folders. like file1,file2 in folder1 and file1 and file2 in folder2. I would like to compare all the similar... (3 Replies)
Discussion started by: gmahesh2k
3 Replies

8. UNIX for Dummies Questions & Answers

report generation

Hello, I got a requirement in writing a sheel script in unix, please help me out the requirement is there are two folders Folder1 and Folder2 and there are same files in the different folders. like file1,file2 in folder1 and file1 and file2 in folder2. I would like to compare all the... (2 Replies)
Discussion started by: gmahesh2k
2 Replies

9. Shell Programming and Scripting

awk- report generation from input file

I have input file with below content: Person: Name: Firstname1 lastname1 Address: 111, Straat City : Hilversum Person: Name : Fistname2 lastname2 Address: 222, street Cit: Bussum Person: Name : Firstname2 lastname3 Address: 333, station straat City: Amsterdam I need... (6 Replies)
Discussion started by: McLan
6 Replies

10. Shell Programming and Scripting

Oracle Report generation

Hi, I am beginner in shell programming.In a shell script i found a call to a script 'runrep25m',which i think is to generate oracle reports?Could anyone help me by providing some details about its usage With Thanks & Regards Dileep (7 Replies)
Discussion started by: DILEEP410
7 Replies
Login or Register to Ask a Question