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 » IBM MQ Installation/Configuration Support » Problem with dspmq in shell script

Post new topic  Reply to topic
 Problem with dspmq in shell script « View previous topic :: View next topic » 
Author Message
hilltops
PostPosted: Thu Mar 09, 2006 6:29 am    Post subject: Problem with dspmq in shell script Reply with quote

Centurion

Joined: 01 Mar 2006
Posts: 112

Has anyone had to write a shell script to capture running queue managers on a linux machine, and then perform some logic basic on the queue manager names, as given below?


#!/bin/bash
set -x
touch hellotesting1
files="$(ls -1)"
qmgrs="$(dspmq | grep -i running | cut -d "(" -f2 | cut -d ")" -f1)"
echo "queue managers $qmgrs"
for q in $qmgrs
do
touch hellotesting.$q
done

My problem is that when I run this script manually it works OK, but when it is configured to be run from cron, the for loop doesn't get evaluated. Is there a problem with the way dspmq returns?

Thankx
Back to top
View user's profile Send private message
xxx
PostPosted: Thu Mar 09, 2006 6:48 am    Post subject: Reply with quote

Centurion

Joined: 13 Oct 2003
Posts: 137

just give the full path in corn for all the executables
Back to top
View user's profile Send private message
hilltops
PostPosted: Thu Mar 09, 2006 6:55 am    Post subject: Reply with quote

Centurion

Joined: 01 Mar 2006
Posts: 112

Don't quite understand your suggestion to give the full path in cron. By the way I forgot to mention how it is called from cron. cron is configure in the following way

* * * * * ~mqm/qmgrs/tester > /dev/null 2>&1


where tester contains the code given above.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Mar 09, 2006 6:58 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

xxx meant that you should replace "dspmq" with "/usr/mqm/bin/dspmq" or wherever dspmq is on your system.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
hilltops
PostPosted: Thu Mar 09, 2006 7:17 am    Post subject: Reply with quote

Centurion

Joined: 01 Mar 2006
Posts: 112

I have now got the line

qmgrs="$(/usr/bin/dspmq | /bin/grep -i running | /usr/bin/cut -d "(" -f2 | /usr/bin/cut -d ")" -f1)"

in place, but i still get the same result, ie the for loop does't get evaluated.

Tanx
Back to top
View user's profile Send private message
wschutz
PostPosted: Thu Mar 09, 2006 7:32 am    Post subject: Reply with quote

Jedi Knight

Joined: 02 Jun 2005
Posts: 3316
Location: IBM (retired)

if it were me....I'd echo the output of dspmq and start debugging from there.....[/quote]
_________________
-wayne
Back to top
View user's profile Send private message Send e-mail AIM Address
hilltops
PostPosted: Thu Mar 09, 2006 7:58 am    Post subject: Reply with quote

Centurion

Joined: 01 Mar 2006
Posts: 112

With a bare minimum script such as the following and with echoing into the testing file, I get nothing in the qmgrs variable when run via cron.

#!/bin/bash
set -x
qmgrs="$(/usr/bin/dspmq)"
echo "queue managers $qmgrs" >> testing
for q in $qmgrs
do
touch hellotesting.$q
done
Back to top
View user's profile Send private message
tkane
PostPosted: Thu Mar 09, 2006 9:07 am    Post subject: Reply with quote

Voyager

Joined: 23 Dec 2002
Posts: 82
Location: Kansas City

Try something more in your crontab. Here's what I have for my 5.3 system:
Code:

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=mqm
HOME=/home/mqsupt/mqm
LD_ASSUME_KERNEL=2.4.19
00 22 * * 0   /var/mqm/scripts/saveqmgr > /dev/null 2>&1


Tom
Back to top
View user's profile Send private message
hilltops
PostPosted: Thu Mar 09, 2006 9:40 am    Post subject: Reply with quote

Centurion

Joined: 01 Mar 2006
Posts: 112

Thank Tom,

I have now got it working. I added the LD_ASSUME_KERNEL=2.4.19 in the crontab file, so it now looks like;

LD_ASSUME_KERNEL=2.4.19
* * * * * ~mqm/qmgrs/tester > /dev/null 2>&1

Many thankx
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Mar 09, 2006 11:56 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Ah! A new thing I learned today. I didn't know you could treat crontab as a shell script like that, to set environment variables.

I'd have left crontab alone, and added the variables to the tester.sh script, myself - because then it's explicit what tester.sh needs, rather than implicit.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
euphoria
PostPosted: Thu Mar 09, 2006 2:32 pm    Post subject: Reply with quote

Acolyte

Joined: 08 Feb 2004
Posts: 51

New thing to me as well.

If you set environment variables in crontab, would they apply for all the cron entries (following the variables) or just the one immediately below ?
Back to top
View user's profile Send private message
wschutz
PostPosted: Thu Mar 09, 2006 4:45 pm    Post subject: Reply with quote

Jedi Knight

Joined: 02 Jun 2005
Posts: 3316
Location: IBM (retired)

might that be just GNU?
Quote:
Environment variables can be set in the crontab. In BSD or ATT, the environment handed to child processes is basically the one from /etc/rc.

_________________
-wayne
Back to top
View user's profile Send private message Send e-mail AIM Address
jefflowrey
PostPosted: Thu Mar 09, 2006 5:18 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

wschutz wrote:
might that be just GNU?

Are you trying to say that it's Not Unix?
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
wschutz
PostPosted: Thu Mar 09, 2006 5:20 pm    Post subject: Reply with quote

Jedi Knight

Joined: 02 Jun 2005
Posts: 3316
Location: IBM (retired)

sorry Jeff... I meant to say: GNU's Not UNIX
_________________
-wayne
Back to top
View user's profile Send private message Send e-mail AIM Address
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Installation/Configuration Support » Problem with dspmq in shell script
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.