Running bash command in ReadyAPI groovy steps
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Running bash command in ReadyAPI groovy steps
Hello Team,
I have created a groovy step in my test case to execute the below bash command. When I try to run this command, then I get a below error from execution. I have tried the number of different things to make the bash command work but I didn't found any solution so far.
OS: mac
bash command:
def process = "aws-azure-login".execute()
process.waitFor()
log.info "Output: " + process.text
log.info "Exit code: " + process.exitValue()
Error:
ERROR: An error occurred [Cannot run program "brew": error=2, No such file or directory], see error log for details
Also, just to make sure I have created 'bashCommand.groovy' class file in my visual studio and that is working fine but not sure why the same thing is not working in ReadyAPI groovy steps. So far I have noticed that when I pass any other command like the below examples then they are working fine.
Working bash cmd:
bash --version
java --version
Can anyone please help me to understand what I am doing wrong?
Please note that my E2E test needed more than one bash command to run so I can't use '.sh' option because those commands needed to run in different intervals.
Note: After installing ReadyAPI in my Mac machine, I have not added any additional files to the package folder (bin or ext). I hope that is not an issue.
Please advise if you have anything suggestion for me to try?
Thanks
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
def process = "aws-azure-login".execute()
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@sam2009 most likely error is your command line. you can paste your command line here if no concern or you can try a simple command to try. for example: def cmd = "ls -la".execute()
// Here is an example (on windows) to call command (or shell)
// you can check it with zsh / bash command on your Mac
try {
def cmd = "cmd /c cd /d \"${toolDir}\" & tool.exe \"${outputDir}\" \"${logDir}\" "
log.info(cmd)
def output = cmd.execute()
def out = new StringBuffer()
def err = new StringBuffer()
output.waitForProcessOutput(out, err)
if (output.exitValue()) {
log.error(err)
} else {
log.info(out)
}
} catch(Exception e) {
testRunner.fail("Cancelled!!! => $e")
}
Thanks,
/Aaron
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks a lot, Aaron and Rao!
@sam2009 did you find the replies helpful?
Sonya Mihaljova
Community and Education Specialist
