Solved

unix scripting task

Posted on 2008-06-12
5
215 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
  • 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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

810 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