Forum Discussion

massimo's avatar
massimo
Occasional Contributor
9 years ago

Executing external program with groovy

In a groovy teststep I add the execution of a teraterm macro to connect on remote host: 

 

def teraterm_path = "C:\\Program Files (x86)\\teraterm"

def process = "$teraterm_path\\ttpmacro.exe SNODO-TestAut-UM-iSSW_IMCS-CP-1.TTL".execute()

process.waitFor()

def value = process.exitValue()

 

Inside the macro file I set the exitvalue (0=OK, 1=KO).

 

All works fine, but I have the following problem: if the macro file is not present the exitValue is still 0; there is a way to identify that the external program was not executed ?

3 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    Did not get what is macro file? do you mean ttpmacro.exe file?
    Also did not get "Inside the macro file I set the exitvalue"
  • nmrao's avatar
    nmrao
    Champion Level 3
    Just a thought.
    The process can be executed based on a condition i.e., if macro file exists then execute the process, so that you do not run into the problem at all.
    Does it make sense?
  • massimo's avatar
    massimo
    Occasional Contributor

    I solved modifying the return code from the external files: (1=OK, 2=KO)