Solved

unix scripting task

Posted on 2008-06-12
5
222 Views
Last Modified: 2013-12-26
Hai !
       the task is as below.

i need to develop a shell script which reads a data file.

The data file looks like this:

profile:     SYSTEM.DEFAULT.MODEL.QUEUE
object type: queue
entity:      mqm
entity type: group
authority:   allmqi dlt chg dsp clr
- - - - - - - -
profile:     SYSTEM.ADMIN.CHANNEL.EVENT
object type: queue
entity:      mqm
entity type: group
authority:   allmqi dlt chg dsp clr
- - - - - - - -
profile:     SYSTEM.DEAD.LETTER.QUEUE
object type: queue
entity:      mqm
entity type: group
authority:   allmqi dlt chg dsp clr
- - - - - - - -
profile:     SYSTEM.CICS.INITIATION.QUEUE
object type: queue
entity:      mqm
entity type: group
authority:   allmqi dlt chg dsp clr
- - - - - - - -
profile:     SYSTEM.CLUSTER.TRANSMIT.QUEUE
object type: queue
entity:      mqm
entity type: group
authority:   allmqi dlt chg dsp clr
- - - - - - - -
profile:     TEST.A
object type: queue
entity:      lwcd
entity type: group
authority:   allmqi dlt chg dsp clr
---------------------------


The script should read profile and entity type  where entity is not mqm.

and display the profile and enitity type combinations on to screen.

How to do this.?



0
Comment
Question by:vishali_vishu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 40

Accepted Solution

by:
omarfarid earned 500 total points
ID: 21771655
cat file | while read profile
do
   read l2
   read l3
   read l4
   read l5
   read l6
   set $l3
   if [ $2 != mqm ]
   then
         echo $profile
         echo $l3
   fi
done
0
 
LVL 1

Author Comment

by:vishali_vishu
ID: 21772088
excellent.... i want even to place the condition object type: queue  only to be selected .

can you modify to add the (and condition).
0
 
LVL 29

Expert Comment

by:MikeOM_DBA
ID: 21772724

Try:

awk -F: '/profile/ {printf "%s",$2;} /entity type/ {print $2;}' my_data
0
 
LVL 29

Expert Comment

by:MikeOM_DBA
ID: 21772821

Oooh, a condition?
OK:



awk -F: ' /profile/{p=$2}/object type/{o=$2}/entity type/{if (o==" queue") print p": "$2;}' my_data

Open in new window

0
 
LVL 40

Expert Comment

by:omarfarid
ID: 21772890
cat file | while read profile
do
   read l2
   read l3
   read l4
   read l5
   read l6
   set $l2
   obj=$2
   set $l3
   if [ $2 != mqm -a $obj = queue ]
   then
         echo $profile
         echo $l3
   fi
done
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question