How to write Perl Script to Get MQ Queue Depth?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to write Perl Script to Get MQ Queue Depth?
# 1  
Old 01-13-2015
How to write Perl Script to Get MQ Queue Depth?

Hi ,

I got the following script from internet to display queue depth using Perl Script. However, when I execute it , im getting following error. Can anyone shed light on what is going wrong?
Code:
 
 
#!/usr/bin/perl
## 07/23/01
## Depth Inquiry sample program. 
## Arguments: [Queue Name] [Queue Manager Name]
## Connects to the queue manager specified by the command line,
## if not supplied, it will connect to the default queue manager.
## It then inquires about the queue name passed in, specifically,
## the current depth of that queue. This is displayed to the user.
## This code can easily be modified to display other queue properties.
## Furthermore, MQINQ can be used to inquire about the attributes of
## other objects, not just queues.
##
## Author: Brandon Duncan
##         brandon@mqseries.net
##         www.mqseries.net
##
use MQSeries;
my $qname = $ARGV[0];
my $qmgrname = $ARGV[1];
my $Hconn = MQCONN($qmgrname, $CompCode, $Reason);
print"MQCONN reason:$Reason\n";
my $ObjDesc = { ObjectType => MQOT_Q, ObjectName => $qname };
my $Options = MQOO_INQUIRE | MQOO_SET | MQOO_FAIL_IF_QUIESCING;
my $Hobj = MQOPEN($Hconn,$ObjDesc,$Options,$CompCode,$Reason);
print"MQOPEN reason:$Reason\n";
my $tst = MQINQ($Hconn,$Hobj,$CompCode,$Reason,MQIA_CURRENT_Q_DEPTH);
print"Depth of $qname is: $tst\n";
MQCLOSE($Hconn,$Hobj,$COptions,$CompCode,$Reason);
print"MQCLOSE reason:$Reason\n";
MQDISC($Hconn,$CompCode,$Reason);
print"MQDISC reason:$Reason\n";

Exception:

Code:
 
bash-3.2$ perl mq.prg Queue1 Server1
 
Can't locate MQSeries.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8 .) at mq.prg line 19.
BEGIN failed--compilation aborted at mq.prg line 19.

# 2  
Old 01-13-2015
The perl program is unable to find MQseries.pm in perl include path (@INC).

Code:
use lib "/path/to/yourmqseriesmodules/"
...<program code>...

# 3  
Old 01-13-2015
Im sorry but I have little idea about perl modules.

Im assuming that we have to check for MQseries.pm module and get its path. How do I know whether it exists and how to find the path?
# 4  
Old 01-13-2015
The Module is publicly published on the comprehensive perl archive network

try running (as root ideally)
Code:
$ cpan
...
cpan> install MQSeries
...
cpan> exit
$ perl mq.prg Queue1 Server1

# 5  
Old 01-13-2015
It is giving the following error, repeated a no of times. I cant run as root. I don't have the permission Smilie

Code:
 
System call "/usr/bin/wget -O - "ftp://ftp.perl.org/pub/CPAN/modules/03modlist.data.gz"  > /home/user1/.cpan/sources/modules/03modlist.data"
returned status 1 (wstat 256)
Warning: expected file [/home/user1/.cpan/sources/modules/03modlist.data.gz] doesn't exist
Issuing "/usr/bin/ftp -n"
ftp: ftp.perl.org: Name or service not known
Not connected.
Local directory now /home/user1/.cpan/sources/modules
Not connected.
Not connected.
Not connected.
Not connected.
Not connected.
Not connected.
Bad luck... Still failed!
Can't access URL ftp://ftp.perl.org/pub/CPAN/modules/03modlist.data.gz.
Please check, if the URLs I found in your configuration file () are valid.
The urllist can be edited. E.g. with 'o conf urllist push ftp://myurl/'
Could not fetch modules/03modlist.data.gz
Going to write /home/user1/.cpan/Metadata
Warning: Cannot install MQSeries, don't know what it is.
Try the command
    i /MQSeries/
to find objects with matching identifiers.
cpan> i /MQSeries/
No objects found of any type for argument /MQSeries/

# 6  
Old 01-13-2015
You don't have access to the CPAN repository from your host?

You could take the required module code from these links
https://metacpan.org/source/MQSERIES...34/MQSeries.pm
https://metacpan.org/source/MQSeries::Config::Machine

and copy them into your PERL5LIB path (you may have to set up a PERL5LIB path in your environment eg. export PERL5LIB=${HOME}/Perl5/lib in ${HOME}/.profile)

Then create the files as
${PERL5LIB}/MQSeries.pm
and
${PERL5LIB}/MQSeries/Config/Machine.pm
This User Gave Thanks to Skrynesaver For This Post:
# 7  
Old 01-14-2015
Hi,

Thanks for all the help so far. Can you please let me know if the below process is fine.

(i) Create the directory - /home/user1/Perl5/lib

(ii) Put the files in

/home/user1/Perl5/lib/MQSeries.pm
/home/user1/Perl5/lib/MQSeries/Config/Machine.pm

(iii) Make a new entry in /home/user1/.profile as -
export PERL5LIB=${/home/user1}/Perl5/lib

---------- Post updated at 02:52 AM ---------- Previous update was at 02:25 AM ----------

I think I was mistaken. We have to put these files in /usr/lib/Perl5. I don't have permission to do that even. I have contacted MQ Team to check whether we can install MQ Series module via a change request.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

MQ Queue depth.

Hi All, We have SuoOs and Linux servers. May i know how do we find the queue depth of IBM MQ from server. (2 Replies)
Discussion started by: Girish19
2 Replies

2. Shell Programming and Scripting

Perl script to create/write into spreadsheet

Hi, I need help in debug following script. can somebody help....!!! #!/usr/bin/perl -w use strict; use Spreadsheet::WriteExcel; # Create a new workbook called simple.xls and add a worksheet. my $workbook = Spreadsheet::WriteExcel->new('simple.xls'); my $worksheet =... (1 Reply)
Discussion started by: chettyravi
1 Replies

3. Shell Programming and Scripting

Need a UNIX/perl script to read and write the data

Hi, I have on Designdocument in that information is stored with in tabular format.I need Perl/unix script to read and write the data using perl script? Regards, Ravi (4 Replies)
Discussion started by: toravi.pentaho
4 Replies

4. Shell Programming and Scripting

Need a perl script to read and write the data

Hi, I have on Designdocument in that information is stored with in tabular format.I need Perlscript to read and write the datausing perl script? Regards, Ravi (0 Replies)
Discussion started by: toravi.pentaho
0 Replies

5. Shell Programming and Scripting

How to write a update query in perl script?

can any one suggest me on how to write a update query in perl script for Oracle database and also tell me abt how we can write a code for sending mails with report as attachment to appropriate persons? (1 Reply)
Discussion started by: Ramesh V Kumar
1 Replies

6. Shell Programming and Scripting

perl script to check read/write/execute permission for 'others'

I want to check access rights permissions not for 'user', not for 'group', but for 'others'. I want to do it by system command in which i want to use 'ls -l' and 'awk' command. I have written the following program : #!/usr/bin/local/perl #include <stdlib.h> system ("ls -l | awk... (1 Reply)
Discussion started by: shubhamsachdeva
1 Replies

7. Shell Programming and Scripting

perl script to find, write, repeat...

I am a novice writing perl scripts so I'd appreciate any help you guys can offer. I have a list of 100 words in a file (words.txt) and I need to find them in a second file (data.txt). Whenever one of these words is found I need to write that line to a third file (out.txt) and then continue... (1 Reply)
Discussion started by: tgamble
1 Replies

8. UNIX for Dummies Questions & Answers

Should I write a PERL Script or Shell Script?

Hello, I have done some BASIC shell scripting/PERL scripting before so I am familiar with the languages. I am not really sure which one would lend itself better to the application I have to write. I am required to scan the message logs for possible break in attempts. If I use shell scripting... (2 Replies)
Discussion started by: mojoman
2 Replies

9. Shell Programming and Scripting

Need help to write a Perl script

Hello friends, I am having a awk script which does my goal , but I want to learn perl , after learning the basics in perl now I am trying to convert my nawk script to perl . Please help me to do some task in perl that I ve already did in nawk. Like I am facing some problem in... (10 Replies)
Discussion started by: user_prady
10 Replies

10. Shell Programming and Scripting

mq queue depth

hi how to find the queue depth of MQ Queue using unix please its very urgent (0 Replies)
Discussion started by: Satyak
0 Replies
Login or Register to Ask a Question