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 » General IBM MQ Support » Script for putting Test Message on a Queue

Post new topic  Reply to topic Goto page 1, 2  Next
 Script for putting Test Message on a Queue « View previous topic :: View next topic » 
Author Message
elixir9999
PostPosted: Thu Oct 08, 2015 6:34 am    Post subject: Script for putting Test Message on a Queue Reply with quote

Novice

Joined: 24 Sep 2015
Posts: 10

Hi

I was trying to write a script to put a test message on a local Q.

But when I write amqsput Q QMGR in the script and the message below it,The control goes from the Script to amqsput and expects a manual entry or a test message at the console.

Can someone please tell me how to tackle this thing, so it puts the message written in the same script in the below line of amqsput command.

Thanks
Sumit
Back to top
View user's profile Send private message
smdavies99
PostPosted: Thu Oct 08, 2015 6:39 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

Code:

amqsput MYQUEUE MYQMGR < inputfile.txt


and you have the message that you want to send on one line in the file.
Have more than one line, and you send one message per line
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Thu Oct 08, 2015 6:57 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

please don't use large font sizes.
_________________
chmod -R ugo-wx /
Back to top
View user's profile Send private message
elixir9999
PostPosted: Thu Oct 08, 2015 8:23 am    Post subject: Reply with quote

Novice

Joined: 24 Sep 2015
Posts: 10

Hi smdavies99

I tried with the below and placed a file msg.txt in the same directory as the script with content of the msg.txt as "TEST".

Now the amqsput starts finds the correct Q but then closes without putting any message on the Q itself.

What am I missing here.

Thanks
Sumit
Back to top
View user's profile Send private message
bruce2359
PostPosted: Thu Oct 08, 2015 9:33 am    Post subject: Re: Script for putting Test Message on a Queue Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 9469
Location: US: west coast, almost. Otherwise, enroute.

elixir9999 wrote:
Hi

I was trying to write a script to put a test message on a local Q.

But when I write amqsput Q QMGR in the script and the message below it,The control goes from the Script to amqsput and expects a manual entry or a test message at the console.

Can someone please tell me how to tackle this thing, so it puts the message written in the same script in the below line of amqsput command.

Thanks
Sumit

Working as designed.

The IBM-supplied amqsput sample program does not look at the lines below it. Rather, amqsput expects input from STDIN to populate the application data portion of the message. STDIN is your keyboard OR a redirected file. Such as:
amqsput QL.A QMC01 <my.data
_________________
I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live.
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Oct 08, 2015 9:46 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

elixir9999 wrote:
What am I missing here.


A '<' character?
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
bruce2359
PostPosted: Thu Oct 08, 2015 10:24 am    Post subject: Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 9469
Location: US: west coast, almost. Otherwise, enroute.

Vitor wrote:
elixir9999 wrote:
What am I missing here.


A '<' character?

It's the redirect (in) character in both Windoze and UNIX. The redirect (out) character is >
_________________
I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live.
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Oct 08, 2015 10:27 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

bruce2359 wrote:
Vitor wrote:
elixir9999 wrote:
What am I missing here.


A '<' character?

It's the redirect (in) character in both Windoze and UNIX. The redirect (out) character is >


I was speculating if the OP used:

Code:
amqsput Q QMGR < msg.txt


or

Code:
amqsput Q QMGR msg.txt

_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
elixir9999
PostPosted: Fri Oct 09, 2015 4:07 am    Post subject: Reply with quote

Novice

Joined: 24 Sep 2015
Posts: 10

Thanks alot Everyone, you guys are great help to new beginners like me.

I had 1 more query, Its working now with < character but if I want to do the same thing with a single script only, can that be done too - I mean the contents of msg.txt are also in the same script file and amqsput picks the msg from the same script only and puts the msg and closes.Can this also be done - everything in a single Script ??

Thanks
Sumit
Back to top
View user's profile Send private message
smdavies99
PostPosted: Fri Oct 09, 2015 4:45 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

This is not really an MQ problem but a Windows one.
That said, something like
Code:

echo "Hello world" | amqsput MYQUEUE  MYQMGR

will do the job.
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
elixir9999
PostPosted: Fri Oct 09, 2015 5:32 am    Post subject: Reply with quote

Novice

Joined: 24 Sep 2015
Posts: 10

Hi Jedi

Thanks for the Helpful reply.

But If i want to put a long MQ or xml msg onto the Q , can I do that through the Script , a single script which picks the msg from within and puts the msg onto the Q.

Thanks
Sumit
Back to top
View user's profile Send private message
Vitor
PostPosted: Fri Oct 09, 2015 5:40 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

elixir9999 wrote:
But If i want to put a long MQ or xml msg onto the Q , can I do that through the Script , a single script which picks the msg from within and puts the msg onto the Q


Two points:

- The amqsput sample application is just that - a sample. If it doesn't do what you want (e.g. doesn't handle long messages, doesn't read directly from a file system) then change it;

- There are many other tools available to manipulate queues that do handle long messages and XML; RFHUtil comes immediately to mind but there are others. You may find these suit you better.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
elixir9999
PostPosted: Fri Oct 09, 2015 5:56 am    Post subject: Reply with quote

Novice

Joined: 24 Sep 2015
Posts: 10

Hi Vitor

Yes, its correct what you are saying.

But our requirement is to integrate MQ with TWS, so that at a specific time in day, TWS will login to the server and execute the script and put the message on the Q and trigger the msg flow at a fixed time each day.

Thanks
Sumit
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri Oct 09, 2015 5:58 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Also, there's no such thing as an XML message.

There's only an MQ Message.

Regardless of what it holds. It could hold XML, it could hold JSON, it could hold a MIME document, it could hold a COBOL record, it could hold a PDF, it could hold a NSFW jpg.
_________________
chmod -R ugo-wx /
Back to top
View user's profile Send private message
Vitor
PostPosted: Fri Oct 09, 2015 6:07 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

elixir9999 wrote:
But our requirement is to integrate MQ with TWS, so that at a specific time in day, TWS will login to the server and execute the script and put the message on the Q and trigger the msg flow at a fixed time each day.


Then you'd probably want something a bit more "production strength" than the sample code anyway (better error handling and logging for example) so my comment about changing the sample (or using it as a template for your own utility) applies.

As my most worthy associate correctly points out, there's no such thing as an "XML message"; just a message that holds XML. If you don't want to view it as XML (which is a feature of RFHUtil) but just put a message on a queue that happens to contain XML then clearly this kind of technology suits you.

It sounds to me like you need to extend or replace amqsput with something that suits you better.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » General IBM MQ Support » Script for putting Test Message on a Queue
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.