2

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?

MrPickles
  • 1,255
  • 1
  • 16
  • 31

1 Answers1

2

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.

Phaaze
  • 66
  • 2
  • where is that file located? I can't find it anywhere. – MrPickles Aug 06 '14 at 16:34
  • 1
    Tilde (~) is just an alias for your home directory on Unix (and Windows actually). On windows I would look in C:\Users\ and on linux/mac I would look in /home/. – Phaaze Aug 06 '14 at 17:16
  • You could also change that file path to be anything on your system. it could be `C:\tempfile` (for Windows) or `/tempfile` (for Linux/Mac) if either of those are more convenient. – Phaaze Aug 06 '14 at 17:16
  • Does it write it on the VNC or the actual computer your using? I still can't find it on either. Maybe I need to add a dot after the `/` in `~/tempfile`? – MrPickles Aug 07 '14 at 16:10
  • 1
    The dot did the trick. I found the file on the system I am using. – MrPickles Aug 07 '14 at 16:13
  • 1
    Update: `shell()` now returns output except on Windows. This question appears to use a Bash shell, and could `put shell("cat login.txt") into output`, for example. – GetHacked Jul 27 '18 at 14:15