0

I want to read bas queue names inside the queues, have written code but which only able to read the last queue name instead of all.

Below is a code

queueList = AdminConfig.list('MQQueue', AdminConfig.getid('/Cell:' + AdminControl.getCell() + '/')).splitlines()


for queue in queueList:

           print "\t" + queue +"in QueueList"

queueName = AdminConfig.showAttribute(queue, 'baseQueueName')

print queueName

The queue is reading only the last queue name from queueList, I want it to read all the base queue names present inside queues.

JoshMc
  • 10,239
  • 2
  • 19
  • 38
Rancho
  • 15
  • 5
  • Don't you need to indent the last 2 lines to make them part of the for loop? Right now it will print the `in QueueList` message for each queue but only the `QueueName` on the last queue. – JoshMc May 23 '20 at 18:17
  • I formalized the information into an answer. Please let me know if you have any further questions or need any clarification. – JoshMc May 24 '20 at 08:59
  • Thanks a lot for this help, I tried as earlier you mentioned and that worked for me. – Rancho May 24 '20 at 14:50

1 Answers1

0

Your script as currently written will only execute the following line for each queue in the queueList:

print "\t" + queue +"in QueueList"

You need to indent the last 2 lines to make them part of the for loop, otherwise they are only executed once after the loop is finished, at that point queue will have the value of the last queue.

queueList = AdminConfig.list('MQQueue', AdminConfig.getid('/Cell:' + AdminControl.getCell() + '/')).splitlines()


for queue in queueList:

           print "\t" + queue +"in QueueList"

           queueName = AdminConfig.showAttribute(queue, 'baseQueueName')

           print queueName
JoshMc
  • 10,239
  • 2
  • 19
  • 38