How can i run windows commands through webMethods?

Hi Experts,

            I want to run windows commands through webMethods like running batch file or any commands. please help me.

Just the same as how you do it with Java, and there is a build-in service pub.utils.executeOSCommand may be useful.

1 Like

Thank you Xiaowei Wang,

                                What is the syntax to specify in "allowedOSCommands="

I want to specify ‘fc’ command in allowed commands. I have specified like this, its not working.

allowedOSCommands=fc
allowedWorkingDirectories=E:\wMFiles

What do you mean “its not working”, you get some error?

As I know, you need to specify any parameter you used in allowedOSCommands, not just command name. For exmaple:

allowedOSCommands=fc fileA fileB

Yes i am getting the below error. I Specified as you said, but still getting error.

com.wm.app.b2b.server.ServiceException: [ISS.0086.9277] Specified command [fc E:\wMFiles\Email_FF.txt E:\wMFiles\PurchaseOrder.txt] is not on the allowedOSCommands list in the OSCommands.cnf file

Here i am passing input for command is “fc E:\wMFiles\Email_FF.txt E:\wMFiles\PurchaseOrder.txt”

Please try to add the command below into OSCommands.cnf file.
fc E:\\wMFiles\\Email_FF.txt E:\\wMFiles\\PurchaseOrder.txt

Files with the extension .cnf are not allowed as attachment in the message.

So i am pasting the content of My OSCommands.cnf

allowedOSCommands=fc E:\wMFiles\Email_FF.txt E:\wMFiles\PurchaseOrder.txt
allowedWorkingDirectories=E:\wMFiles

Change the command in OSCommands.cnf to
fc E:\\wMFiles\\Email_FF.txt E:\\wMFiles\\PurchaseOrder.txt
And don’t change the service input

Changed the command in OSCommands.cnf

allowedOSCommands=fc E:\\wMFiles\\Email_FF.txt E:\\wMFiles\\PurchaseOrder.txt
allowedWorkingDirectories=E:\wMFiles

Service input
command

1)fc E:\\wMFiles\\Email_FF.txt E:\\wMFiles\\PurchaseOrder.txt

2)fc E:\wMFiles\Email_FF.txt E:\wMFiles\PurchaseOrder.txt

tried both, getting same error.

Did u refer the built in services reference guide for wM 8.1.2?

Yeah, they mentioned like

For example, if the allowed command is cmd.exe /c c:/temp/ab;c.txt , specify it as cmd.exe /c
c:/temp/ab\;c.txt when specifying it as a parameter for the OSCommands.cnf file.

Did you reload the WmPublic package? And in your case, working directory input is not required, please notice that.

Didn’t specified the Working directory and Restarted the server.

Getting same error.

Strange, I test in my environment, it works fine.
Can you save the input of executeOSCommand into file system, and attache this pipeline data and your OSCommands.cnf, so I can verify it in my environment.

Files with the extension .cnf and .Input are not allowed as attachment,

so i am uploading the OSCommands.cnf Image

Input command

fc E:\wMFiles\Email_FF.txt E:\wMFiles\PurchaseOrder.txt

Otherwise tell me for basic dir command syntax, i will try for it later.

I need exactly the files to reproduce your problem, the string you typed may make me confuse, for example there is a space char at the end of your command input.

I use the attached OSCommands.cnf, and load pipelinedata.xml as input, then successfully run the command as result.png. You can try them in your environment.
pipelinedata.xml (231 Bytes)
result.png
OSCommands.cnf.txt (113 Bytes)

Its working Xiaowei Wang.

I really appreciate your patience in problem solving. Thank you very much.

Hello,

I am also having problems running windows commands through webMethods. Is there a basic example that will work that I can try and test with?

This is the command I execute from the command line:
C:>xcopy.exe c:\MyText.txt c:\Text\MyText.txt

The command I want to execute the same command from webMethods.

Also where is this OSCommands.cnf file located? Is it somewhere on the integration server?

Thanks

Hi Fred,

You can execute xcopy.

I guess webMethods 8.X and above has this file, located at : C:\SoftwareAG\IntegrationServer\packages\WmPublic\config\

Please make use of config file shared by Wang.

HTH.

Thanks,
Rankesh

Yes, we have the OSCommands.cnf file from webMethods 8 and above.

The OSCommands.cnf configuration file in the Software AG_directory\Integration
Server\packages\WmPublic\config directory contains parameters that Integration Server uses to provide validation checks to make the pub.utils:executeOSCommand service secure.