Wednesday, April 13, 2011

capture debug log of my bash script

#!/bin/sh

export PS4='$0.$LINENO+ '
exec > /tmp/TTpull.log
exec 2>&1
set -x


This is how I like to capture - now what those above means?

The PS4 i already explained in my previous post. The $0 variable holds the name of the script. $LINENO displays the current line no. within the script. The exec command redirects I/O streams. to a file /tmp/TTpull.log. 2>&1 redirects stderr and stdout. and finally - 'set -x' enables debugging.


Cheers!
DK

No comments:

Post a Comment

CICD Assessment

( A story on -  how we formulated a process around measuring and achieving CICD, and  how these journey lines has now become a means t...