-1

I have to make Groovy Test Step in SOAPUI which pass variables to sh script and then run it in putty.

I have created this simple Groovy script:

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

and this sh script:

#!/bin/bash

sleep 2
grep '$VARIABLE' /path/to/log/file.log
sleep 10​

Is there any way to define $VARIABLE in Groovy script and then get the value to sh script?

Thanks

5
  • you can pass it as a parameter to script. and in script just assign VARIABLE=$1 Commented Nov 26, 2018 at 14:04
  • Also also see Run shell script (with parameters) on Windows command line via Plink to understand that what you pass to PuTTY -m switch is NOT a shell script. Commented Nov 26, 2018 at 14:39
  • Putting the variable in single quotes means it is just a literal string. Probably see also stackoverflow.com/questions/6697753/… Commented Nov 27, 2018 at 4:54
  • @tripleee As I've mentioned above, the file that OP passes to PuTTY -m switch is not a shell script, so this does not really matter. Commented Nov 27, 2018 at 6:55
  • May I suggest you adjust the header of your question to not include "SoapUI", and also remove the "soapui" tag, as you - as I see it - aren't using SoapUI at all. Commented Nov 28, 2018 at 9:46

1 Answer 1

-1

After reading resolutions from links you commented here I decided to create sh. file on the fly.

Thanks to everyone

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

2 Comments

Please accept that your question is duplicate, instead of posting a duplicate (and incomplete) answer. –
I wanted to accept that my question is duplicate. But I don't have the "Accept as duplicate" button.