When I want to redirect output from a Linux command line into a file (capture the output of a command), I use redirection (>).
ls -l / > /path/to/log/dir/filename.log 2>&1
the command is: ls -l /
the greater than symbol (>) tells it to put the output (stdout) into the following file
the filename is: /path/to/log/dir/filename.log (This can be the full path or the relative path with the filename at the end.
2>&1: This tells it to send stderr (error messages) to the same address as stdout (output). That way stdout and stderr both go in the file you gave it. (0 = stdin; 1 = stdout; 2 = stderr; & = address)
I think you should be able to use the same syntax when you use the agent to execute a command.
Hope this helps,