-2

I need to execute unix command/shell script on unix system by SoapUI tool. SoapUI is installed on windows machine.

  1. How to make ssh connection by SoapUI to unix machine?
  2. How to run the command?
  3. How to capture the output of this command?
Rao
  • 20,781
  • 11
  • 57
  • 77
user1700502
  • 51
  • 1
  • 7
  • Use jsch library and write code for the same. Check this please for sample - http://stackoverflow.com/questions/2405885/run-a-command-over-ssh-with-jsch – Rao Oct 05 '16 at 12:17

1 Answers1

2

You can use the folowing code:

def process = 'ssh user@host myCommand'.execute()
process.waitFor()
println process.in.text
println process.err.text

You can execute it as a testSuite or testCase setUp/tearDown script, script test step or any other place where groovy can be executed.

If that is possible, I recommend to configure the authentication with keys, so that you will not be asked for a password when making a connection.

You can also execute multiple commands within a single connection:

def process = 'ssh user@host "myCommand1; myCommand2; myCommand3"'.execute()

I prefer using the && operator to execute the command only if the previous finished successfuly, i.e.:

ssh user@host "myCommand1 && myCommand2 && myCommand3"
KarelHusa
  • 1,995
  • 18
  • 26
  • How can we run multiple command by single coonection : Like we need to redirect to require directory then run the command – user1700502 Oct 06 '16 at 17:39
  • @user1700502, you might noticed that the answer is updated by KarelHusa showing multiple commands. If you find answer useful, you can upvote :) – Rao Oct 10 '16 at 09:38