Not getting how to write

Hi Team,

I am trying for below requiremebt but not getting how to go.

When i give below command

 amqrfdm -m SUN

it gives the output as below

amqrfdm for v7.0
Date(2013-08-12 )Time(14.06.42)
Version(7.0.1.3)(p701-103-100813)
Product(WebSphere MQ for Solaris (SPARC platform))
#) Summary
q) Print Cluster Queues
T) Print Cluster Topics
S) Print Cluster TopicStrings
s) Print Subscriptions
m) Print Cluster Queue Managers
o) Output entire cache
a) Print Free Areas
r) Print Registrations
d) Dump Area of repository
t) Browse Transmission Queue
D) Disconnect
f) Set Filters (Off)
+) Set Details level
Enter option character Q - Quit

from above i need to select "t"
then it gives output as below

Channel Msgs Bytes
-------------------- ----- --------
AA.BB.C1 3 1382
BB.DD.C1 4 1897
DD.QQ.C1 6 1978

this ouput should be saved into a file.
At present i am working on this requirement. I wrote below lines in script but it is not working. From above example QMGR is SUN

#!/bin/ksh
QMGR=$1
echo "enter QM"
read QMGR
echo "amqrfdm -m $QMGR"
print "t" > chl.txt

Please help me how to go ahead

Try:

QMGR=$1
while [ -z "$QMGR" ]; do
  printf "Enter QM: "
  read QMGR
done

echo t | amqrfdm -m "$QMGR" > chl.txt

Try echo t | amqrfdm -m $QMGR

--ahamed

It got stuck after entering QMGR name, not giving any outpuy

Maybe it needs a Q too?

printf "t\nQ\n" | amqrfdm -m "$QMGR" > chl.txt

Assuming the program can read from standard input.

Or perhaps the program does not write to standard output? Is there any screen output?

#!/bin/ksh
QMGR=$1
while [ -z "$QMGR" ]; do
printf "Enter QM: "
read QMGR
done
echo t | amqrfdm -m "$QMGR" > chl.txt
 

above one is creating file chl.txt but ouput is repeating untill mountpoint gets full.

output:

amqrfdm for v7.0
Date(2013-08-12 )Time(15.01.27)
Version(7.0.1.3)(p701-103-100813)
Product(WebSphere MQ for Solaris (SPARC platform))
#) Summary
q) Print Cluster Queues
T) Print Cluster Topics
S) Print Cluster TopicStrings
s) Print Subscriptions
m) Print Cluster Queue Managers
o) Output entire cache
a) Print Free Areas
r) Print Registrations
d) Dump Area of repository
t) Browse Transmission Queue
D) Disconnect
f) Set Filters (Off)
+) Set Details level
Enter option character Q - Quit
Channel Msgs Bytes
-------------------- ----- --------
CLUSTER1.TESTENV1.C1 3 1382
#) Summary
q) Print Cluster Queues
T) Print Cluster Topics
S) Print Cluster TopicStrings
s) Print Subscriptions
m) Print Cluster Queue Managers
o) Output entire cache
a) Print Free Areas
r) Print Registrations
d) Dump Area of repository
t) Browse Transmission Queue
D) Disconnect
f) Set Filters (Off)
+) Set Details level
Enter option character Q - Quit
Channel Msgs Bytes
-------------------- ----- --------
CLUSTER1.TESTENV1.C1 3 1382
#) Summary
q) Print Cluster Queues
 

I want output to show like below as well as save in a file, example

once we give QMGR (SUN) name then it should display below output only

Channel Msgs Bytes
-------------------- ----- --------
CLUSTER1.TESTENV1.C1 3 1382
 

it should be saved in a file and script should get closed

Try post#5

--ahamed

It is giving output twice as below. I want output to be shwon also after editing.

"chl.txt" 38 lines, 996 characters
amqrfdm for v7.0
Date(2013-08-12 )Time(16.18.50)
Version(7.0.1.3)(p701-103-100813)
Product(WebSphere MQ for Solaris (SPARC platform))
#) Summary
q) Print Cluster Queues
T) Print Cluster Topics
S) Print Cluster TopicStrings
s) Print Subscriptions
m) Print Cluster Queue Managers
o) Output entire cache
a) Print Free Areas
r) Print Registrations
d) Dump Area of repository
t) Browse Transmission Queue
D) Disconnect
f) Set Filters (Off)
+) Set Details level
Enter option character Q - Quit
Channel Msgs Bytes
-------------------- ----- --------
CLUSTER1.TESTENV1.C1 3 1382
#) Summary
q) Print Cluster Queues
T) Print Cluster Topics
S) Print Cluster TopicStrings
s) Print Subscriptions
m) Print Cluster Queue Managers
o) Output entire cache
a) Print Free Areas
r) Print Registrations
d) Dump Area of repository
t) Browse Transmission Queue
D) Disconnect
f) Set Filters (Off)
+) Set Details level
Enter option character Q - Quit
~

I want output as

Channel Msgs Bytes
-------------------- ----- --------
CLUSTER1.TESTENV1.C1 3 1382

Try this

...
printf "t\nQ\n" | amqrfdm -m "$QMGR" > chl.txt
awk '/Q - Quit/{p=1;next}p&&/#) Summary/{exit}p' chl.txt

--ahamed

You say it's "giving output twice"... that's to be expected.

But is that output to the screen, or output to the file (chl.txt)?

@Ahmed:

Getting output in chl.txt as below

WebSphere MQ Repository Query Program written by Paul Clarke
Usage : amqrfdm [-m QMgrName] [-d]

@scott:

gettin output in chl.txt file, it is not getting displayed

Run only the awk command.
Don't you already have the output in chl.txt?

--ahamed

It is also giving same output

WebSphere MQ Repository Query Program written by Paul Clarke
Usage : amqrfdm [-m QMgrName] [-d]