IBM Support

Issue running complex commands on Windows FTAs

Troubleshooting


Problem

All jobs do not run if you define a job to run two or more Windows commands, or .CMD files, separated by the ampersand (&) character. Only the first command in the chain is executed and the second command is ignored.

Symptom

For example, to write a job to execute cmd1.cmd and cmd2.cmd, the syntax is:

cmd1.cmd & cmd2.cmd

Only cmd1.cmd is executed; cmd2.cmd is ignored.

Environment

Tivoli Workload Scheduler (TWS) v8.6 agent running on Windows operating system.

Resolving The Problem

This resolution applies to all TWS versions 8.6.0 and above.

To run a chain of Windows commands in Windows jobs, some changes have to be done to the jobmanrc.cmd file and jobs have to be defined in a slightly different way.

Changes to jobmanrc.cmd file

1. Ensure that the :getargs function is defined in the following way (if not, change it as described below):

:getargs
set ARGS=%*

2. Ensure that :launch_args function is defined in the following way (if not, change it as described below).

Add yes_local_rc and no_local_rc if needed and ensure that no_local_rc is changed as in the following.:

:launch_args
REM Launch job based on ARGS (JCL)
if /I "%LOCAL_RC_EXISTS%"=="YES" (goto :yes_local_rc) else (goto :no_local_rc)

:yes_local_rc
"%USERPROFILE%\djobmanrc.cmd"
goto :continue

:no_local_rc
set doublequote=%ARGS:~0,1%

set TEST=%doublequote:"=X%

if "%TEST%" == "X " (goto :remove_and_launch) else (goto :launch)

:launch
call %ARGS%
goto :continue

:remove_and_launch
call %ARGS:~1,-1%
goto :continue

:continue

NB:“X<space><space>”





Changes to Job definition:

Change the job definition, adding an additional double quote at the beginning and at the end of the command. For example, change the following composer definition:

WIN-V91#CHAIN
DOCOMMAND "dir & echo hi"
STREAMLOGON mdm91
DESCRIPTION "Aggiunto da composer."
TASKTYPE WINDOWS
RECOVERY STOP

to this:

WIN-V91#CHAIN
DOCOMMAND "\"dir & echo hi\""
STREAMLOGON mdm91
DESCRIPTION "Aggiunto da composer."
TASKTYPE WINDOWS
RECOVERY STOP

The objective of these changes is to avoid having jobmanrc.cmd process the command as part of its processing. One way to avoid jobmanrc processing the "&" inside the command is to include it between double quotes (see the job definition at step 2) that have to be removed just before calling the command (call %ARGS:~1,-1%).

[{"Product":{"code":"SSGSPN","label":"IBM Workload Scheduler"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Not Applicable","Platform":[{"code":"PF033","label":"Windows"}],"Version":"8.6;9.1;9.2;9.3;9.4","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
17 June 2018

UID

swg21996703