Error if i wrap the command :- stafclient.stafexception: '"SC QUERY Audiosrv"' is not recognized as an internal or external command,operable program or batch file.
I am getting following error when i wrap the command using STAFUtil.wrap(command).
stafclient.stafexception: '"SC QUERY Audiosrv"' is not recognized as an internal or external command,operable program or batch file.
Following request gives me the error :-
STAF local Process START SHELL COMMAND STAFUtil.wrap(command) WAIT RETURNSTDOUT STDERRTOSTDOUT"
Command = "SC QUERY <Service-Name>"
If i exclude "STAFUtil.wrap()" then command executes fine.
Following request gives successful results :-
STAF local Process START SHELL COMMAND command WAIT RETURNSTDOUT STDERRTOSTDOUT"
Command = "SC QUERY <Service-Name>"
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
How are you submitting the STAF PROCESS START request? Is this via the STAF command executable from a command prompt or .bat file? If so, there isn't a STAFUtils.wrap() function for the STAF command executable.
Or are you using a <process> element in a STAX job? If so, here's an example of a STAX job that runs fine:
#!/usr/bin/pythonfromPySTAFimport*importsystry:handle=STAFHandle("MyTest")exceptSTAFException,e:print"Error registering with STAF, RC: %d"%e.rcsys.exit(e.rc)# Here's a PROCESS START example using the wrapData() function to wrap the COMMAND option's valuecommand="SC QUERY Audiosrv"request="START SHELL COMMAND %s WAIT RETURNSTDOUT"%(wrapData(command))result=handle.submit("local","PROCESS",request)ifresult.rc!=0:print"ERROR: Received RC: %d, Result: %s"%(result.rc,result.result)sys.exit(1)mc=unmarshall(result.result)output=mc.getRootObject()['fileList'][0]['data']printoutput# Here's a PROCESS START example using double quotes to wrap the COMMAND option's value# Note used single quotes around the request value so could use double quotes within it without# having to excape them.request='START SHELL COMMAND "%s" WAIT RETURNSTDOUT'%(command)result=handle.submit("local","PROCESS",request)ifresult.rc!=0:print"ERROR: Received RC: %d, Result: %s"%(result.rc,result.result)sys.exit(1)mc=unmarshall(result.result)output=mc.getRootObject()['fileList'][0]['data']printoutput# Here's a PROCESS START example using double quotes to wrap the COMMAND option's value# Note since used double quotes around the request value have to escape the double quotes# with a backslash when used within the request value.request="START SHELL COMMAND \"%s\" WAIT RETURNSTDOUT"%(command)result=handle.submit("local","PROCESS",request)ifresult.rc!=0:print"ERROR: Received RC: %d, Result: %s"%(result.rc,result.result)sys.exit(1)mc=unmarshall(result.result)output=mc.getRootObject()['fileList'][0]['data']printoutput############## Finish up ##############result=handle.unregister()if(result!=STAFResult.Ok):print"Error unregistering with STAF, RC: %d"%resultsys.exit(result)sys.exit(0)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I am getting following error when i wrap the command using STAFUtil.wrap(command).
stafclient.stafexception: '"SC QUERY Audiosrv"' is not recognized as an internal or external command,operable program or batch file.
Following request gives me the error :-
STAF local Process START SHELL COMMAND STAFUtil.wrap(command) WAIT RETURNSTDOUT STDERRTOSTDOUT"
Command = "SC QUERY <Service-Name>"
If i exclude "STAFUtil.wrap()" then command executes fine.
Following request gives successful results :-
STAF local Process START SHELL COMMAND command WAIT RETURNSTDOUT STDERRTOSTDOUT"
Command = "SC QUERY <Service-Name>"
How are you submitting the STAF PROCESS START request? Is this via the STAF command executable from a command prompt or .bat file? If so, there isn't a STAFUtils.wrap() function for the STAF command executable.
Or are you using a <process> element in a STAX job? If so, here's an example of a STAX job that runs fine:
Or are you submitting the PROCESS START via a Python script? If so, here's an example showing three different ways that work:
I am submitting STAF request from JAVA using submit2() method.
I am creating a request object
request = stafServiceCommandAction + " SHELL COMMAND " + STAFUtil.wrapData(command.toString().trim()) + " WAIT RETURNSTDOUT STDERRTOSTDOUT";
Then submitting it to STAF submit2()
handle.submit2(machineName,stafServiceName,request);
Works fine for me. Here's an example submitting a "SC QUERY Audiosrv" command and using STAFUtil.wrapData around it in a PROCESS START request:
Here's its output: