shelltestingeggplant

How to retrieve output from Eggplant shell script command


Trying to retrieve the output of my shell command, so I assign it to a variable and try to log it via the LogSuccess command.

put shell ("cat login.txt") into myOutput
LogSuccess myOutput

Unfortunately, I don't see anything in the logs or anyway to know that the command was actually sent to the shell. Anyone know what I'm missing?


Solution

  • The current eggPlant API does not return the output of the shell() command. A decent solution is to redirect the output of a command to a file, and read it immediately.

    set destinationFile to "~/tempfile"
    shell "cat login.txt > " & tempFile
    
    LogSuccess file destinationFile
    

    The above code sample will show you the output of the command.