Re: Running a Script- and debugging.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 09/22/09 10:52, quoth Jim:
> FC11/KDE
> 
> I have a script to run for setting up a Samsung CLX3175FN, when I start
> it it hangs. and doesn't say why , how can I find why it hangs ?
> 
> I'm running it from the terminal as root.
> 

Something I've used for years that has served me well:

export PS4='+${0##*/} line $LINENO: '

Put that in your .bash_profile (or in your .bashenv which is sucked in when
you log in, like I do).

Also, if you code for debugging, life gets easier:

errmsg()
{
    echo -e "$@" 1>&2
}

derrmsg()
{
    ((debug)) && errmsg "$@"
}

die()
{
    errmsg "$@"
    exit 1
}

You can then add calls to getops to activate debug mode.

typeset -i seen_d=0
typeset -i seen_D=0
typeset debug=0
typeset opt

usage()
{
    typeset err="$1"
    errmsg "$err"
    cat << EEIIEEIIOO 1>&2
Usage: $prog [-d] [-D] blah blah blah
EEIIEEIIOO
    exit 1
}
prog=${0##*/}
while getopts :dD opt $@
do
    case ${opt} in
    d)
        (( seen_d == 1 )) && usage 'too many -d' || seen_d=1
        debug=1
        ;;

    D)
        (( seen_D == 1 )) && usage 'too many -D' || seen_D=1
        set -x	# or whatever you need
        ;;
    h | *)
        usage 'Help text or unknown option'
        ;;
    esac
done


-- 
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net

Attachment: signature.asc
Description: OpenPGP digital signature

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines

[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux