Executing Unix script from webmethods

I’ve a situation where I need to run a Unix script from webmethods. How do I achieve this. Server may not be running on the same box or there may not be any IS on the box where the scripts reside. I should be able to invoke this remotely.



You could do a java.lang.Runtime:exec() of SSH to the remote box and use SSH to execute your script.

Venkat, the solution can be found in this thread:

Good luck!


Thanks Guys. That helped me. But I have another problem. The actual script to run is as follows.
su - omidevl -c “/opt/omi/utility/scripts/uuts702 WPUJ130”.

I had problems in java for the double quotes. I used the escape character and finally I could get the command string into the method. Runtime.getRuntime().exec().
But it is not executing it and returns the code 0f 1.
I added the string to the pipeline.
When I copied the same and run on the console it runs fine.
So, in Runtime.getRuntime().exec() method it is getting confused.

Then I created another script to hold the entire command ran that script alone. It worked fine.

But I want to know, why it is not working when I pass the whole string to exec() method.



Ensure that you’re catching the stderr of the executable: see java.lang.Process (getErrorStream).

There’s a post floating around on wmusers where this is discussed. I had a quick look through the archives but it wasn’t immediately obvious. If you can’t find it google on Runtime.exec(…) and look for discussions about using InputStreams to hook up to the stdout, stdin, and stderr or executables.



I think you may be required to use escape \ for the quotes in your command.

I am trying to run an unix script using webmethods.The command used is-

bdf -l |awk ‘{print $1,$5,$6}’ >/packages/**/config/DiskMonitoring1.txt

Currently i am getting this error–

“bdf: |awk: No such file or directory
bdf: ‘{print: No such file or directory
bdf: $1,$5,$6}’: No such file or directory
bdf: >/packages/***/config/DiskMonitoring1.txt: No such file or directory”.

Any solution to this?


I believe it is due to your path structure - use …/ instead of / to begin your path…

can u explain it? dint get yur reply here…

Tell us more about how you are calling the unix script (are you using PSUtilities command line exec tool, are you calling it from your java script, etc)?

The more detail you give, the more likely someone can help without just taking a guess - as I did last post. :slight_smile:

we are facing similar problem…could you please let us know how you fixed the error.thanks