-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

  • you can pass it as a parameter to script. and in script just assign `VARIABLE=$1` – daggett Nov 26 '18 at 14:04
  • 1
    Possible duplicate of [How to pass argument to PuTTY commands file](https://stackoverflow.com/questions/36335882/how-to-pass-argument-to-putty-commands-file) – Martin Prikryl Nov 26 '18 at 14:38
  • Also also see [Run shell script (with parameters) on Windows command line via Plink](https://stackoverflow.com/q/27462589/850848) to understand that what you pass to PuTTY `-m` switch is NOT a shell script. – Martin Prikryl Nov 26 '18 at 14:39
  • Putting the variable in single quotes means it is just a literal string. Probably see also https://stackoverflow.com/questions/6697753/difference-between-single-and-double-quotes-in-bash – tripleee Nov 27 '18 at 04: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. – Martin Prikryl Nov 27 '18 at 06: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. – Steen Nov 28 '18 at 09:46

1 Answers1

-1

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

Thanks to everyone

  • Please accept that your question is duplicate, instead of posting a duplicate (and incomplete) answer. – – Martin Prikryl Dec 03 '18 at 11:40
  • I wanted to accept that my question is duplicate. But I don't have the "Accept as duplicate" button. –  Dec 04 '18 at 12:25