ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Technologies FAQ » Cmd Line editing and Cmd Recall for MQSC.....Updated

Post new topic  Reply to topic
 Cmd Line editing and Cmd Recall for MQSC.....Updated « View previous topic :: View next topic » 
Author Message
csmith28
PostPosted: Tue Jan 20, 2004 2:43 pm    Post subject: Cmd Line editing and Cmd Recall for MQSC.....Updated Reply with quote

Grand Master

Joined: 15 Jul 2003
Posts: 1197
Location: Arizona


Well there isn't one, once you type runmqsc there is no command recall and the only editing option you have is the backspace and arrow keys but for the people running MQSeries on UNIX and to a certain extent DOS there are ways to issue MQSC commands and have command line editing and command recall.

On Unix platforms simply set your shell to ksh and set your editor to vi as in
# ksh
# set -o vi

Then use the following syntax:

# echo "dis ql (*) curdepth" | runmqsc QMGR01

Then if you want the output sent to a file:

# echo "dis ql (*) curdepth" | runmqsc QMGR01 > /tmp/disqlout
> will clobber an existing file with the new output
>> will abend to the end of an existing file

This allows you to use vi, view, more or cat to see the contents of the file file or save the output for later use.

If you don't recall the exact name of specific QL and you know a unique portion of the name of the object then:

# echo "dis ql (*)" | runmqsc QMGR01 | grep STRING

(note you can use this syntax in DOS to but don't use the quotes)
(note this will also allow you to imbed MQSC command in simple shell scripts)

If you want to know the number of running channels on QMGR01 then do this:

# echo "dis chs (*)" | runmqsc QMGR01 | grep -v grep | grep RUNNING | wc -l

(note do not use the "all" argument in the dis chs when running this or you will get a line count for all the MCASTAT instances of RUNNING doubling you total)

In Unix you can use Esc-k to recall the most recent command and edit it.
(note Esc-k is reading the .sh_history file)

Continue hitting k to move farther backward in the command history. You can use j to move forward.

(note in DOS us the up arrow to move backward and the down arrow to move forward in the command history but this only works in an existing DOS Command Window instance)

You can edit the command lines using normal vi commands like l to move left, h to move right, i to insert text etc.

(note in DOS use your arrow keys, delete and backspace and when typing changes keep in mind that you are alway in insert mode)

Also in Unix if you want to search your history hit Esc-K then / and type the string you are looking for. For example

# /ql

will find the most recent ql in you .sh_history. Then you can type n to get to the next instance of ql in your .sh_history.

I suppose if you wanted to use another Unix editor like Emacs you could but I prefer vi because it is included in almost if not all flavors of Unix.

Also, this works for regular Unix commands aswell. For example if you type

# ps -ef | gerp -v grep | grep mqm | wc -l > mqmproc.out

you will get an error "gerp not found"

Hit Esc-K, use the l to move left until the cursor is on the e in gerp and type xp. xp will switch the position of the e and the r so that gerp is grep then hit Enter.

When I was first exposed to these little tricks I didn't give them much credence. Then after time I started using them more and more often. Now I can't imagine not using them.

What is the curdepth now? How about now? Now? OK fine...

# while true
# do
# echo "dis ql(SYSTEM.DEAD.LETTER.QUEUE) CURDEPTH" | runmqsc MQMGR
# echo "dis ql(APP.QUEUE) CURDEPTH" | runmqsc MQMGR
# sleep 15
# clear
# done


Makes life easier for me so I thought I would share it.
_________________
Yes, I am an agent of Satan but my duties are largely ceremonial.


Last edited by csmith28 on Wed Dec 22, 2004 4:58 pm; edited 18 times in total
Back to top
View user's profile Send private message
csmith28
PostPosted: Wed Dec 22, 2004 3:33 pm    Post subject: Reply with quote

Grand Master

Joined: 15 Jul 2003
Posts: 1197
Location: Arizona

updated and corrected
_________________
Yes, I am an agent of Satan but my duties are largely ceremonial.
Back to top
View user's profile Send private message
dove-young
PostPosted: Thu Feb 21, 2008 6:30 pm    Post subject: Reply with quote

Newbie

Joined: 21 Feb 2008
Posts: 9

Hi!

You can make your life even easier by using Emacs as I am doing everyday.

Just start up your Emacs and then press Meta-x and input shell.

I mean to run a shell inside the Emacs and issue MQSC command via runmqsc.

In the shell inside Emacs, you can leverage all the full sceen editor facilities provided by Emacs in your Shell environment and you can just point your cursor to an old command and press Enter to re-run it.

If you want to edit an exising command, just point your cursor to it and edit it on the screen and then press Enter.

Have a good life.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Technologies FAQ » Cmd Line editing and Cmd Recall for MQSC.....Updated
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.