Redirect STDOUT to log file

smp (34 posts)
May 8, 2009 09:28 AM
Accepted Answer

adTempus 3.0.5

I have a scheduled job which executes a perl script. The perl script outputs some information to STDOUT, which I can redirect to a log file when I execute the command from the command line like this:

F:\jobs\script.pl > logs\script.log

In the job step I have the following:
Target:    "F:\jobs\script.pl"
Command-Line Parameters: "> logs\script.log"
Startup Directory: "F:\jobs"

I have the Window Mode set to normal, and have tried every different "User Interaction" value. In no case am I able to capture the output of the script into "logs\script.log", though I know the script runs successfully. I can capture the output if use the "Capture Console" Window Mode. But would using a "Normal" Window Mode prevent the script from processing the Command-Line Parameter?

This topic has an accepted answer. Jump to it.
Bill Staff (599 posts)
May 8, 2009 12:17 PM
Accepted Answer

You cannot include the redirection operator in the command-line parameters box, because it's not a command-line parameter to the script--it's an instruction to the command shell to grab the output. When the command gets executed through adTempus, it doesn't get processed by the command shell, so that doesn't mean anything.

If you want adTempus to capture the console output, omit the redirection operator and set the window mode to "Capture Console". adTempus will then grab anything that gets written to stdout.

If you want the output to go to a file, you can use a batch file that runs

 f:\jobs\script.pl > logs\script.log

 and have adTempus run the batch file with "normal" window mode. Since it's now the command shell that's executing the command, the redirection operator gets processed. You can then add a Response with a File Capture Action if you want to grab that log file and keep it in the job history.


smp (34 posts)
May 8, 2009 07:37 PM
Accepted Answer
What a great explanation - thanks so much!
Paul Watson (101 posts)
November 30, 2012 10:01 AM
Accepted Answer
Is it possible to capture stderr also? If so, how?
Bill Staff (599 posts)
November 30, 2012 11:27 AM
Accepted Answer
If you are using the "Capture Console" option in adTempus, the stderr output should be going to the console capture file along with the stdout. Same thing if you're redirecting in a batch file using ">"--stderror should be getting written to the same file.

Replies are disabled for this topic.