1

I have shell script which is kept on remote server(linux machine) and I am trying to call that shell script in between the execution of various test cases of SOAPui from windows. So I have prepared a groovy script:

def command="/usr/bin/ssh -p password username@IP_address bash -s < /home/test.sh"
def proc=command.execute().text
proc.waitFor()

But unfortunately, I am receiving an error:

java.io.IOException: Cannot run program "/usr/bin/ssh": CreateProcess error=2, The system cannot find the file specified error at line: 6

I tried to search more on this, but couldn't get the resolution. Some of the links were:

How to execute shell script using soapUI

http://groovy-lang.org/groovy-dev-kit.html#process-management

4
  • If you're executing the SOAPUI on Windows you can not use /usr/bin/ssh since the command.execute() is running locally and in Windows you don't have /usr/bin/ssh. Try to install a ssh client for Windows and use it in your command. Commented Apr 21, 2016 at 12:10
  • I got that we can't use /usr/bin/ssh, but I need to execute script only from soapui tool in windows. So how will I able to execute from ssh client for windows(like putty,etc)? Commented Apr 21, 2016 at 12:21
  • I put a sample using putty take a look on it :) Commented Apr 21, 2016 at 13:15
  • Possible duplicate of How can I execute Linux commands on a remote machine using Java? Commented Apr 21, 2016 at 16:34

1 Answer 1

1

If as you comment you've a putty.exe installed on Windows you can try with the follow.

First of all create a file in your Windows local with the commands to execute remotely for example I create the follow C:/temp/commandsToRunRemotely.txt then in this file put the command you want to execute. As a sample I use the follow command:

echo "test remote execution" > /tmp/myfile.txt

Then from groovy script in SOAPUI call putty.exe passing the local file which contains the commands to execute remotely:

def command = "C:/path/to/putty.exe -ssh user@IP -pw pass-m C:/temp/commandsToRunRemotely.text"
def proc = command.execute()
proc.waitFor()

Note that if you've putty.exe in your Windows path, you can simply use putty.exe instead of full path.

This is only an ilustation sample, but if you want to execute a shell script remotely instead of echo "test remote execution" > /tmp/myfile.txt in the commands file use directly the path for your script: /home/test.sh

I get the Putty command line options from this nice answer

Hope it helps,

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the expert answer. But, still the query persists i.e. if we are executing the whole suite of soapui through command line. And that command will send by Jenkins to some servers(new windows machine), which will make us mandatory to first install putty. Is there any other alternative without running from putty or some ssh tool?
@Nikhil this change your original question since your original question simply want to execute remotely a shell script from a Windows to Linux using SOAPUI... besides in your comment you literally told "So how will I able to execute from ssh client for windows(like putty,etc)?" Then I take putty as a possible option for you... this new constraint make IMO a new question. Please post this as a new question specifying carefully all details :).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.