execute shell script on 20 IS's


I started working on this recently and got into a trouble. Please help me on how to execute a shell script using a java service written in webmethods service development.

So far my progress is as follows:
I was able to login using ssh…verified on the unix shell and it is working.

I am unable to do the following.
cd to a specific directory and
invoke the shell script.

public static final void invokeOScommand(IData pipeline)
throws ServiceException {
IDataCursor idc = pipeline.getCursor();
long connectionTimeout = 600;
long readTimeOut = 600;
String hostname = IDataUtil.getString( idc, “hostname” );
String username = IDataUtil.getString( idc, “username” );
String password = IDataUtil.getString( idc, “password” );
String command = IDataUtil.getString( idc, “command” );
//String commands = {“su - vkb”,“sh”};
String directory = IDataUtil.getString( idc, “directory” );

	String curr_status= null;
			Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
			SshParameters sshParams = new SshParameters (hostname,username,password);
			Ssh ssh = new Ssh(sshParams);
			String status = "OK,Connected";
			// get OutputStream
			OutputStream out = ssh.getOutputStream();
			// define command to perform directory listing
			command = "sh startup.sh"; 
			// send command to SSH server
			// write CRLF to indicate end of command
			IDataUtil.put( idc, "ssh_object", ssh );
			IDataUtil.put( idc, "status", status );
		catch (Exception e) {
			throw new ServiceException("SystemLogger: Could not resolve syslog host. [java.net.UnknownHostException]");

Tried to use the firecommandexec but i was unable to make it work in Unix, ahy help would be appreciated,

Hi Kama,

can you explain your business requirement a bit more in detail please?

Which wM version are you on?


using webmethods 9.6

requirement was to cleanup all the logs in the IS’s each month after during restart . I have a unix script that has all the directories it need to go to and cleanup .This needs to be invoked without logging into the hosts and then traversing to the directory.My aim was to have a java service which can login to a unix host and then initiates that clean up script.

Coming backto my questions, Integration Server is totaled at 20. I will have a flow which will over write hostname and port that can login to all the different 20 hosts.

Hope i am clear enough


What is the error you are receiving?

Best Regards,

problem is it doesn’t do ‘cd’ to that directory. where i have to issue that command.

String commands = {“su - vkb”,“sh”}

I was trying to make sure that it accepts these commands ,


Can you use the built-in SSH File Transfer Protocol (SFTP) api in WmPublic/pub.client.sftp ?

Best Regards

Just trying to understand your logic here…

So will the script you are building with JS needed to be executed on one IS that will handle all the other OS machines hosted IS’s log files clean up? Is that that direction you are going with?

Yeh, why don’t you use WmPublic/pub.client.sftp service having with appropriate commands and manage the creds/path entries via a db?



Very true. I am trying to write this invokeOScommand service and place it on one box which then logs into other Integration servers(already shut) and cd to a directory where my cleanup script is residing. I do not know if i can use pub.client.sftp:cd,pub.client:sftp . I am not sure if these(pub.client…) will server my purpose of invoking a look alike of “sh cleanup.sh”

The problem is the 20 integration servers that i am reachin out to are already in shutdown/disabled mode.

I am not sure if i can use it in my scenario

There is no other way , than to login to the unix box and invoke the shell script.
Also , the problem is i have to have elevated rights to execute this cleanup. Which i get through using “su -”. I am trying to acheive the following.

In sequential

login to the host-i got it completed
‘su-’ not able to complete
cd-not done
sh cleanup.sh-not done


Are you able to execute the operations manually (that is, opening an ssh session and sending each of the operations) from the machine where you have the IS?

Can you execute the same operation through a script on that machine?

Can you run that script from the IS?

Best Regards,