Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Wed 01 Jul 2015, 08:13
All times are UTC - 4
 Forum index » House Training » HOWTO ( Solutions )
How to debug ash/bash shell scripts
Moderators: Flash, Ian, JohnMurga
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 1 of 1 Posts_count_1  
Author Message

Joined: 20 Oct 2005
Posts: 451
Location: Boston MA USA

PostPosted: Thu 22 Dec 2005, 16:07    Post_subject:  How to debug ash/bash shell scripts  

How to debug ash/bash shell scripts

Add echo statements in various places to show what is happening where. $LINENO is available in bash. Use set and env to dump the values of all the variables. In bash, <trap DEBUG> allows added code to be run after each statement.

Two flags are available, -v verbose and -x xtrace. They can be invoked with the start of the script:
# sh -vx scriptfile
or within the script:
set -vx
and can then be turned off within the script:
set +vx

The output can be copied to a logfile:
# sh -vx scriptfile 2>&1 | tee logfile
or redirected from within the script:
exec 1>logfile 2>&1
But that exec statement takes away all the screen output, leaving you running blind. For advanced tips, see:
capture screen output in a file

There is rumored to be a bash debugger for the latest version, but no news yet of any sightings within the known pupverse.
Back to top
View user's profile Send_private_message 
Display_posts:   Sort by:   
Page 1 of 1 Posts_count_1  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » House Training » HOWTO ( Solutions )
Jump to:  

You cannot attach files in this forum
You can download files in this forum

Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0362s ][ Queries: 12 (0.0036s) ][ GZIP on ]