Some command jobs fail that cause a Python script when run through and agent.
search cancel

Some command jobs fail that cause a Python script when run through and agent.

book

Article ID: 280103

calendar_today

Updated On:

Products

Autosys Workload Automation

Issue/Introduction

We have a command job that calls a batch file that runs a Python script to modify an Excel spreadsheet using Excel.
When we run the batch file manually as the job owner on the system it works fine.

When we run the same through as 12.x agent the agent fails with an error message:
.968-0500 CAWA_I_20018 Job failed. Exit code 1, Status: "Incorrect function."

The standard error file from the job shows the following:
Traceback (most recent call last):
  File "<drive>:\<folder1>\<folder2>\test.py", line 8, in <module>
    wb = excel.Workbooks.Open(excel_file_path)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<COMObject <unknown>>", line 5, in Open
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Microsoft Excel', "Microsoft Excel cannot access the file '<drive>:\<folder1>\<folder2>\\test.xlsx'.
There are several possible reasons:\n\n•
The file name or path does not exist.\n•
The file is being used by another program.\n•
The workbook you are trying to save has the same name as a currently open workbook.", 'xlmain11.chm', 0, -2146827284), None)
Traceback (most recent call last):
  File "<drive>:\<folder1>\<folder2>\test.py", line 8, in <module>
    wb = excel.Workbooks.Open(excel_file_path)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<COMObject <unknown>>", line 5, in Open
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Microsoft Excel', "Microsoft Excel cannot access the file '<drive>:\<folder1>\<folder2>\\test.xlsx'.
There are several possible reasons:\n\n•
The file name or path does not exist.\n•
The file is being used by another program.\n•
The workbook you are trying to save has the same name as a currently open workbook.", 'xlmain11.chm', 0, -2146827284), None)

Environment

Windows 2016 server
Autosys Agent 12.x

Cause

the default for the agent is to use a 32-bit command processor.
This was to maintain backward compatibility with 11.x agents
this is controlled by setting the oscomponent.cmdprefix.force to TRUE in the agentparm.txt

Resolution

changed the following parameter in the agentparm.txt:
From:
oscomponent.cmdprefix.force=true
to:
oscomponent.cmdprefix.force=false

and restarted the agent to correct this error.

Additional Information

one way to test this outside the application would be to open a 32-bit Command prompt and then run start the batch file from there and see if you have the same issue.

How do I run a Command Prompt in 32-bit mode?
 
The 32-bit command prompt automatically redirects file system calls to the correct 32-bit directory.
To start a 32-bit command prompt, follow these steps:
Click Start, click Run, type %windir%\SysWoW64\cmd.exe, and then click OK.