-1

I wrote some ugly script of mine and besides giving me what I want in the output it also gives me the status code value.

The script output is below. How do I prevent the script from showing that status code in the output??

P.S. I'll put the script below, hope it wouldn't hurt your eyes too much

    Status code = 0

    Status code = 0

    Status code = 0
    job_1_1_1

    Status code = 0

    Status code = 0

    Status code = 0


    Status code = 0

    Status code = 0

    Status code = 0
    job_1_1_2

    Status code = 0

    Status code = 0

START_ID=`dsjob -logsum -type STARTED  UPSTREAM_MDM_D4  seq_1_1  | nawk 'ORS=(FNR%2)?FS:RS' | grep Starting | tail -1 | awk '{print $1 }'`; FATAL_IDS=`dsjob  -logsum -type INFO UPSTREAM_MDM_D4  seq_1_1  | grep INFO | awk '{print $1 }'`; for TEST_ID in ${FATAL_IDS}; do if [[ "${TEST_ID}" -ge "${START_ID}" ]]; then WARN_DTL=`dsjob  -logdetail UPSTREAM_MDM_D4 seq_1_1 ${TEST_ID}`; if `echo $WARN_DTL|grep -q 'has finished, status = 3'`; then message=`echo $WARN_DTL| grep -oP '\w+(?= has finished, status = 3)'`; fatal_errors=$fatal_errors$'\n'$message;fi; fi;done; echo $fatal_errors
Dominique
  • 16,450
  • 15
  • 56
  • 112
Denys
  • 4,287
  • 8
  • 50
  • 80
  • 1
    Please format your code (proper code tags where they belong, indentation, ...). – Adrian Frühwirth Mar 28 '14 at 11:52
  • We can't know which subcomponent prints this. Try adding `2>/dev/null` to all the `dsjob` invocations, but understand that this will also mute any potentially useful diagnostics. – tripleee Mar 28 '14 at 11:55

1 Answers1

0

You should decide what you want exactly achieve, one of method can be for example:

(
your commands
) 2>&1 | grep -v 'Status code = 0'

Beware - the above is not a good practice - only a quick-hack like solution...

clt60
  • 62,119
  • 17
  • 107
  • 194