A23149577
A23149577

Reputation: 2145

Run OS Commands with MQ Service object - AMQ8734- Command failed - Program could not be started

I want to run a test command on MQ Server Windows Machine remotely. In order to do that, I use SupportPac MO72 and I can successfully connect remotely to MQ Server with Administrator ID. Now I have MQSC console available and I want to run some OS command with creating SERVICE object. I defined my service as:

DEFINE SERVICE('myService') STARTCMD('C:\Windows\System32\PING.EXE 127.0.0.1') SERVTYPE(SERVER) CONTROL(MANUAL)

The service was created successfully and now I want to start this service, so I typed:

START SERVICE(myService)

But I got this error:

AMQ8734- Command failed - Program could not be started

Any idea?

Upvotes: 3

Views: 520

Answers (1)

JasonE
JasonE

Reputation: 2026

There's a combination of things wrong...

  1. Your SERVTYPE(SERVER) is for something which starts running and stays running (and hence whose health is monitored). SERVTYPE(COMMAND) is for something you run and ends. Only a SERVTYPE(SERVER) can be monitored for health but it ought to be long running.

  2. Your startcmd needs to be a binary to launch - just the binary. The STARTARGS need to hold the arguments to the command.

     DEFINE SERVICE('myService') +  
            STARTCMD('C:\Windows\System32\PING.EXE') +  
            STARTARG('127.0.0.1') +  
            SERVTYPE(COMMAND) +  
            CONTROL(MANUAL)  
    

Of course, you might like to see its output - look at the args like STDOUT and STDERR to capture output into a file.

If you want the output to come back to your remote client in a queue it gets a bit more complicated. You would have to capture the output and pipe it through amqsput or some other program to get it onto a queue, then retrieve it. The queue cannot be the same reply queue you are using with MO72 because MO72 would choke on the text, so you would have to use amqsgetc or some other program to fetch the output from the queue.

Upvotes: 4

Related Questions