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 Thu 30 Oct 2014, 12:53
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
kethd

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:
http://www.murga.org/%7Epuppy/viewtopic.php?t=4802
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:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


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