how to define arguments values in input of pub.utils:executeOSCommand service

Hi ,
I am tryin to use pub.utils:executeOSCommand service in wM IS 9.9, for running windows commond. But I am getting error as Invalid argument.
command :findstr /I /M /S “Arsenal” fullyQualifiedPathOfpackageLocation

PFB service inputs I am giving
command:findstr
arguments: /I
/M
/S
“Arsenal”
environment: null
workingDirectory:fullyQualifiedPathOfpackageLocation

OSCommands.cnf setting
allowedOSCommands= findstr;dir
allowedWorkingDirectories= fullyQualifiedPathOfpackageLocation

Please help how do I have to specify argument values

Hi,

Are you trying to find a particular string in a folder\file using that command findstr?

Also can you validate that command with arguments works fine via a putty client ?

HTH,
RMG

1 Like

yes I’m trying to search particuler string via windows command.
yes I tried that command on cmd box it is working fine and giving me correct results.
can you please help how to use arguments for that service.

Hi,

Try using echo instead of findstr to debug what is actually sent to the shell.

I would suspect the workingDirectory argument will need quoting if the value has spaces in it.

Good luck.

PFB things which I tried

1. Ran echo command via executeOSCommand service,with same inputs those are mention above

Result :com.wm.app.b2b.server.ServiceException: java.io.IOException: Invalid argument

2.There is no spaces in working directory still I tried with quotes ,I edited config file with quotes and In service given same path without quotes

Result: com.wm.app.b2b.server.ServiceException: java.io.IOException: Invalid argument

FINDSTR = Searches for patterns of text in files.

Try this it is working as expected

allowedOSCommands=findstr
allowedWorkingDirectories=C:/Users/Mahesh/Desktop/temp

Under the above folder, I have a file called “proposal.txt” which contains “Windows I am ready” and the same file is present in subfolders

When you run the service with below inputs, it will list the expected output. Correct me if there is any issues.

command findstr
workingDirectory C:/Users/Mahesh/Desktop/temp
arguments[0] /m
… /i
… /s
… Windows
… file name or . To search every file in the current directory and all subdirectories that contained the word Windows,

Make sure you reload WmPublic package fully after you make any changes to config file.

Yes this is an post step to note to make the changes work :)-

thank you @RMG and
Special thanks to @Mahesh taking time and trying at your end.
Yes I eqarlier tried with same way the way you have mention I gain retired it but everytime I am getting below error .

Could not run ‘executeOSCommand’
com.wm.app.b2b.server.ServiceException: [ISS.0086.9279] Specified working directory [\Server\c$\SoftwareAG_99\IntegrationServer\instances\default\path] is not on the allowedWorkingDirectories list in the OSCommands.cnf file

after making changes in configFile I reloaded pacakge several times.

It worked for me when I specified path as \server\c$\SoftwareAG_99\IntegrationServer\instances\default\path\

problem with it is it gaves error as INDSTR: Cannot open and FINDSTR: Out of memory

SOLUTION that I have applied as of now I wrote java service to execute command and it is giving me correct results. But it is taking more than 2 min. to fetch the results.
java code is very simple with the use of process = (Runtime.getRuntime()).exec(Command);
It would be very helpful if you give your views on executing command quickly in permisiable time. :slight_smile:

Try with / or //.

Alternatively, you can also try the service in PSUtilities and the implementation should be same as WmPublic.

If you still have issues, contact me via email.