DX NetOps

 View Only

Debugging Scripts - how to do this ...

  • 1.  Debugging Scripts - how to do this ...

    Broadcom Employee
    Posted Jul 31, 2015 11:43 AM

    .. some times you may need to debug "some scripting" .. and it appears these lines here are "sometimes" very useful:

     

    Use the script starting with these initial statements - will create a file (here in the same /tmp/script.<process-id>.out  | you may change to your needs);

    will then redirect STDERR to STDOUT with detailled script interpretation - and will then report the lines "as it is" and how it is when interpreted:

     

    #!/bin/sh

    exec > /tmp/script.$$.out

    exec 2>&1

    set -vx

    PS4='[$0: $LINENO]+ '

    export PS4

     

    Using this for Notifier scripts is very useful in case of customization debugging. Cheers, Joerg