Forum Discussion
Apoorva6
Frequent Contributor
Hi Rup, Thanks for reply, I used both Runtime and Processbuilder, unfortunately I got same error. I just need to go to /home/bgew directory and run a script myScript.sh with an argument my argument .
rupert_anderson
9 years agoValued Contributor
Hi,
I made a simple script:
#!/bin/bash echo "Hello World! $1 $2"
Have you tried anything like:
//method 1 ['/Users/test/soapuiblog/hello.sh', 'arg1', 'arg2'].execute() //method 2 def sout = new StringBuffer(), serr = new StringBuffer()
//def proc = 'ls /temp'.execute()
def proc = '/Users/test/soapuiblog/hello.sh arg1 arg2'.execute()
proc.consumeProcessOutput(sout, serr)
proc.waitForOrKill(1000)
log.info "out> $sout err> $serr"
Method 1 seems to execute without any error, but I couldn't be sure it had worked so I tried a way that captures the output method 2 (based on http://stackoverflow.com/questions/159148/groovy-executing-shell-commands) which also seemed to work giving the below log:
Fri Apr 08 08:50:15 BST 2016:INFO:out> Hello World! arg1 arg2 err>
I ran this in a Groovy TestStep.
Let me know if this works for you?
Regards,
Rup
- rupert_anderson9 years agoValued Contributor
Hi,
Did this work out in the end?
Its a good topic, would be nice to know if its still a problem or theres a solution to share.
Thanks,
Rup
Related Content
- 10 years ago
- 3 years ago
- 5 years ago