cancel
Showing results for 
Search instead for 
Did you mean: 

Call an application running on remote server through command line

SOLVED
Highlighted
New Contributor

Call an application running on remote server through command line

Hi All

I have an application that runs on my test server through command line. Is there a way I can call that application from SoapUi open source installed on my local machine.

Thanks in advance.
1 ACCEPTED SOLUTION

Accepted Solutions
Community Hero

Re: Call an application running on remote server through command line

Short answer

In order to execute a command you need to create a text file that contains the command. This file must be on the same machine as the SoapUI application. You also need to have Putty on the same machine. Then you create a groovy script step and you can execute the command as:

'cmd /c D:\\applications\\putty\\putty.exe -ssh yourserver -l yourusername -pw yourpassword -m D:\\applications\\putty\\commands.txt'.execute()

Long answer

SoapUI can execute cmd commands through groovy scripts. Luckily, putty can be ran from cmd. Smiley Happy

Follow the following steps to be able to run commands from SoapUI in Linux machines:

1. Copy Putty on the same machine as SoapUI.

2. Again, on the same machine as SoapUI create text files containing your commands. Normally you can put multiple commands in the same file when working with Linux but I can't guarantee that. You will need to try it yourself.

3. Open your SoapUI project and add a step of type Groovy script. The synthax for executing a cmd command is:

'cmd /c DUMMYCOMMAND'.execute()

4. The command for running putty is:

putty.exe -ssh hostname -l yourusername -pw yourpassword -m fileFromWhichToExecuteCommands

5. From points 3 and 5 we get then:

'cmd /c putty.exe -ssh hostname -l yourusername -pw yourpassword -m fileFromWhichToExecuteCommands'.execute()

6. Please note that when using putty.exe you also need to specify the path to it. So this would look like

'cmd /c D:\\applications\\putty\\putty.exe...

The same goes for the file containing your commands.

7. If you don't want to worry about point 6, you can always add putty to your Windows path.

 

Considerents

1. If you commit this project in git like this, you will also commit the username and password there, which is a bad practice.

2. Changing properties and restarting servers will increase your test duration. On the long run, it might be useful to find other solutions for this. (like putting property changes in the unit tests instead)



If my answer helped please click on the 'Accept as Solution' button.
5 REPLIES 5
Community Hero

Re: Call an application running on remote server through command line

Hi @gurpreet31 ,

 

That is possible under certain circumstances. What OS do you use and what OS does the test server use?



If my answer helped please click on the 'Accept as Solution' button.
New Contributor

Re: Call an application running on remote server through command line

I am on windows 10 and the server is a linux server
Community Hero

Re: Call an application running on remote server through command line

Short answer

In order to execute a command you need to create a text file that contains the command. This file must be on the same machine as the SoapUI application. You also need to have Putty on the same machine. Then you create a groovy script step and you can execute the command as:

'cmd /c D:\\applications\\putty\\putty.exe -ssh yourserver -l yourusername -pw yourpassword -m D:\\applications\\putty\\commands.txt'.execute()

Long answer

SoapUI can execute cmd commands through groovy scripts. Luckily, putty can be ran from cmd. Smiley Happy

Follow the following steps to be able to run commands from SoapUI in Linux machines:

1. Copy Putty on the same machine as SoapUI.

2. Again, on the same machine as SoapUI create text files containing your commands. Normally you can put multiple commands in the same file when working with Linux but I can't guarantee that. You will need to try it yourself.

3. Open your SoapUI project and add a step of type Groovy script. The synthax for executing a cmd command is:

'cmd /c DUMMYCOMMAND'.execute()

4. The command for running putty is:

putty.exe -ssh hostname -l yourusername -pw yourpassword -m fileFromWhichToExecuteCommands

5. From points 3 and 5 we get then:

'cmd /c putty.exe -ssh hostname -l yourusername -pw yourpassword -m fileFromWhichToExecuteCommands'.execute()

6. Please note that when using putty.exe you also need to specify the path to it. So this would look like

'cmd /c D:\\applications\\putty\\putty.exe...

The same goes for the file containing your commands.

7. If you don't want to worry about point 6, you can always add putty to your Windows path.

 

Considerents

1. If you commit this project in git like this, you will also commit the username and password there, which is a bad practice.

2. Changing properties and restarting servers will increase your test duration. On the long run, it might be useful to find other solutions for this. (like putting property changes in the unit tests instead)



If my answer helped please click on the 'Accept as Solution' button.
New Contributor

Re: Call an application running on remote server through command line

Thank you Lucian...you are a CHAMP
Community Hero

Re: Call an application running on remote server through command line

haha sure Smiley Very Happy glad I could help.



If my answer helped please click on the 'Accept as Solution' button.
New Here?
Join us and watch the welcome video:
Top Kudoed Authors