CA WA Agent : Script execution fails

Document ID : KB000117512
Last Modified Date : 17/10/2018
Show Technical Document Details
CA WA Agent can run scripts.  If the script returns completion code 0 or success the job will be marked as complete.
When executing a script, it is always a best to have some debug messages enabled.  When the script runs, the CA Agent will monitor the script.  Any child processes that are spawned off through the script will not be visible.  If the script returns an exit code of 0, then the CA Agent will mark the job as complete.
CA WA System Agent 
OS: Linux/Windows/UNIX
Debugging of scripts can vary between OS and shell.  Here are some common examples that will enable additional output.  It is recommended to consult the OS and shell manuals for more details on debugging.

Korn and Bash Shells:
Add set -x at the start of the script
set -x

echo "Time is: `date +%H:%M`"


The above script when executed will show each executed line:
[user1@linux ~]# ./ 
++ date +%H:%M
+ echo 'Time is: 17:16'
Time is: 17:16

In Windows, the @ECHO ON will provide similar output.
REM My-script.bat

if exist c:\temp\timbuktu.txt (
REM  file exists
     notepad c:\temp\timbuktu.txt
) else (
REM file doesn't exist
     echo "File Misssing!!"



C:\Temp>REM My-script.bat
C:\Temp>if exist c:\temp\timbuktu.txt (
REM  file exists
 NOTEPAD c:\temp\timbuktu.txt
)  else (
REM file doesn't exist
 echo "File Missing!!"
"File Missing!!"

Additional Information:
Note:  If the script executes another binary, then output of that program may or may not show up.  It is recommend to make sure such executables have been properly set with any environment variables or settings that may be needed.