4 Replies Latest reply on Mar 16, 2018 12:08 AM by Bentze Perlmutter

    Executing Shell Script - Command/Script Mode

    Jasvinder Singh

      Hi All,


      Need your help in understanding the difference when we submit a shell script in Command Mode / Script Mode


      How it differs as far as submission is concerned from Control-M??


      We are submitting in Script mode and getting an output close to 20 Gigs - however user says when he's executing same he's not getting that big logs!

        • 1. Re: Executing Shell Script - Command/Script Mode
          Rick Westbrock

          It appears that the agent is capturing standard out in the job output where you don't see stdout when running the script from the shell. For example I have a small BASH script which when I run it from a shell prompt on the agent (Linux) I get no output unless there is an error. However when I use an OS job to call the script on the same agent the output shows every single line of the script except for comments.


          For example the first three lines of my script are to set variables which I would not expect to see in the job output however they do show up. I also use printf to write an error message to stdout if a config file can't be sourced and when that happens the job shows the actual printf command in the output before it shows the string that gets printed. Both cases are shown in the example output below. When I execute the script from the shell myself I only get back this string "Failed to source the config file /apps/ctm/scripts/ctm/etc/inPlaceholderText.conf, exiting in error."

          Basically all the lines that start with + appear in the job output but not when running the script from a shell prompt.


          I suspect that your script is doing much the same thing but it must be looping lots of files/records or the like to generate job output that large.


          + CONFIG=inPlaceholderText

          + CTMHOME=/apps/ctm

          + SCRIPTS=/apps/ctm/scripts/ctm

          + source /apps/ctm/scripts/ctm/etc/inPlaceholderText.conf

          /apps/ctm/scripts/ctm/bin//zip-unzip.sh: line 44: /apps/ctm/scripts/ctm/etc/inPlaceholderText.conf: No such file or directory

          + printf 'Failed to source the config file /apps/ctm/scripts/ctm/etc/inPlaceholderText.conf, exiting in error.'

          Failed to source the config file /apps/ctm/scripts/ctm/etc/inPlaceholderText.conf, exiting in error.

          + exit 1

          I am currently researching how to get the job output to not show everything as I need to pass a password in a command and obviously don't want the job output to show that. I have a feeling I will have to refactor my script to send the output of sensitive lines to /dev/null instead.

          • 2. Re: Executing Shell Script - Command/Script Mode
            MunKeong Lee

            Hi Rick

            By default, the Unix agent is configured to use the "-x" flag for Bourne/Korn shell script. This will cause the shell to echo commands to the standard output before executing them.

            To disable echo, you can use the CCM to update the flag to "n". You can change this property of the Unix agent using the CCM under the "Job Submission and Tracking" tab. Alternatively, you can run ctmunixcfg on the agent machine.



            • 3. Re: Executing Shell Script - Command/Script Mode
              Rick Westbrock

              Thanks MunKeong Lee one could definitely set that flag for the agent for sure. Another option is to use "set +x" in the script itself to disable the trace/debug mode then use "set -x" later in the script when you want to re-enable trace. I think that you could also add "+x" on the shebang line to disable trace for the entire script which has the advantage of not affecting other scripts.


              Jasvinder Singh I'd try this in your script to see if it resolves your issue of the enormous output volume.

              • 4. Re: Executing Shell Script - Command/Script Mode
                Bentze Perlmutter

                You can disable the -x at the job level only, rather than agent level, by adding this variable to the job:

                %%ECHO_SYSOUT and value of 'n'