Incorrect function error when command uses output redirection

book

Article ID: 74925

calendar_today

Updated On:

Products

CA Workload Automation AE - Business Agents (AutoSys) CA Workload Automation AE - Scheduler (AutoSys) CA Workload Automation Agent

Issue/Introduction

Command job on Windows fails when the command attribute in the job definition (JIL) includes standard error/output redirection (> or >>).
For example:
command: echo %DATE% %TIME% >> C\:\Temp\test.txt

The job log from the failed run shows the following message:
CAWA_I_20018 Job failed. Exit code 1, Status: "Incorrect function."

Cause


Missing System Agent configuration parameter "oscomponent.cmdprefix.force=true" and/or the Windows machine definition missing the "opsys: windows" (JIL) attribute.

Environment

CA Workload Automation AE r11.3.5 and r11.3.6.
CA Workload Automation System Agent 11.3 on Windows.

Resolution

Update the CA WA System Agent agenparm.txt file with the following parameter and restart the CA Workload Automation System Agent service.
"oscomponent.cmdprefix.force=true"

Setting oscomponent.cmdprefix.force=true causes the CA WA System Agent to submit the command using the Windows command interpreter (cmd.exe).

Excerpt from the job log with the aforementioned setting:
CAWA_I_20013 Command to be executed: "C:\Windows\SYSTEM32\cmd.exe" /c echo %DATE% %TIME% >> C:\Temp\test.txt

If "oscomponent.cmdprefix.force=true" is set in the agentparm.txt already, yet the "Incorrect function" error manifests, then ensure the Windows System Agent machine definition has the "opsys: windows" coded (JIL).

Additional Information

We do not recommend using output / error redirection in the command line. Instead, use the std_err_file and std_out_file JIL attributes to achieve the same objective.
For example:
Remove the ">> C\:\Temp\test.txt" bit from the command part of the job definition and add the following attributes:

std_err_file: >> C\:\Temp\test.txt
std_out_file: >> C\:\Temp\test.txt

https://techdocs.broadcom.com/us/en/ca-enterprise-software/intelligent-automation/workload-automation-system-agent/11-4/configuring/configure-the-agent/configure-the-agent-to-behave-like-a-legacy-remote-agent.htmlhttps://docops.ca.com/ca-workload-automation-system-agent/11-4/en/reference/ca-wa-agent-for-unix-linux-windows-or-iseries-agent-parameters#CAWAAgentforUNIX,Linux,Windows,oriSeriesAgentParameters-oscomponent.cmdprefix.force

<Command file not found> error on CA WA System Agent:
https://comm.support.ca.com/kb/command-file-not-found-error-on-ca-wa-system-agent/kb000072530