cannot execute command with executeOSCommand service.

Hi All,
I have a requirement of executing UNIX commands on system for which I am using PS utilities executeOSCommand service.
but when I try this command
find . -mtime +10 -type f -exec cp {} \ directory-name ;
I don’t get any results.
My reqmt is to find all the files last modified 10 days ago and copy them to the specified directory.

Hello,

Please send a screenshot of the input of the service.
You cannot put all the command in the “command” field. You have to make use of the parameters.

If you can’t get what you want, then I suggest just creating a shell script on Unix Filesystem and then just call the shell script from the ExecuteOSCommand service…

Jeremy

1 Like

Hi Jeremy,
Executing commands in a script worked!!!
thanks

Hello, All
I want to invoke the service ps.util.system:executeOSCommand to execute the Linux command "mv /tmp/test/.csv /tmp/test/bak/" , the inputs of the service as follow:
command: mv
arguments: (1)/tmp/test/
.csv
(2)/tmp/test/bak/
workingDirectory: /tmp/test/

An error “mv: cannot stat `/tmp/test/.csv’: No such file or directory" happened, would you tell me how to convert the character "” on this service ? or this service can’t be used like this ?

I create a shell script on Unix Filesystem and then just call the shell script from the ExecuteOSCommand service, it is OK by this way.

Hi Xing,

Did you check whether the command which you are trying to execute is exist as part of OSCommands.cnf file …

Thanks,

Try giving the complete string in the cmd itself.

command: mv /tmp/test/*.csv /tmp/test/bak/

as you are giving the complete path right from the root folder, you need not give the workingDirectory also.
No arguments. Just command string.

/Naidu

I give the complete string “mv /tmp/test/*.csv /tmp/test/bak/” to command only, but the error keeps the same.

Hi,
I checked the file /webmethods/webMethods9/IntegrationServer/packages/WmPublic/config/OSCommands.cnf as below:
allowedOSCommands=mv
allowedWorkingDirectories=/webmethods/SISHARE/SLS/test/

but the error of “mv /webmethods/SISHARE/SLS/test/*.csv /webmethods/SISHARE/SLS/test/bak” keep the same.

I can touch a file named “*.csv” on the linux, so I doubt that the * can’t be used as a wildcard on this service, but how can I use the * as a wildcard like linux command or is it not supporting this function ?

Thanks !

Hi Xing,

Can you please give a try like below :

mv /tmp/test/’*.csv’ /tmp/test/bak/

and let us know what you have observed. At present i don’t have Unix/Linux OS to execute n give you right command in a single short.

Thanks,

Hi MR,

command: mv /tmp/test/’*.csv’ /tmp/test/bak/
the actual filename is abc.csv

The result as following attachment:
errorMessage: mv: cannot stat `/tmp/test/’*.csv’’: No such file or directory.

Please use pub.utils:executeOSCommand which is in WmPublic instead of PSUtilities.

Refer BIS for the usage guidelines.

Hi?M@he$h?
Thanks for your reply.

The service pub.utils:executeOSCommand still can’t identify that the “" is a wildcard or only a common character, so when I want to use ".csv” to filter files “A.csv” and “B.csv”, the command "mv /tmp/test/.csv /tmp/test/bak/" is failed. errorMessage: mv: cannot stat ` /tmp/test/.csv’’: No such file or directory. I had tried to use “." or others instead of "”, but it is bad. What can I do for it ?

you can use: pub.file:listFiles service under WmPublic
to list all files under the directory and copy them one by one.
HTH,