how to debug .sh type script

2010-05-31 Thread Aiza
Is there way to single step through each line of code and see the real 
values of the variables?

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: how to debug .sh type script

2010-05-31 Thread Samuel Martín Moro
echo $my $debugs
read a #(or whatever variable)

until you pressed the enter key (or sig), your script will wait


Samuel Martín Moro
{EPITECH.} tek4
CamTrace S.A.S
 (+033) 1 41 38 37 60
 1 Allée de la Venelle
 92150 Suresnes
 FRANCE

Nobody wants to say how this works.
 Maybe nobody knows ...
 Xorg.conf(5)


On Mon, May 31, 2010 at 9:59 AM, Aiza aiz...@comclark.com wrote:

 Is there way to single step through each line of code and see the real
 values of the variables?
 ___
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to 
 freebsd-questions-unsubscr...@freebsd.org

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: how to debug .sh type script

2010-05-31 Thread Matthew Seaman
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 31/05/2010 08:59:04, Aiza wrote:
 Is there way to single step through each line of code and see the real
 values of the variables?

Not 'single step' as such -- what you can do is run with '-x' which
prints each line as it is executed.  That's either:

   sh -x scriptname

or you can add it to the #! line in the script, or just stick 'set -x'
somewhere in the script body.

If you use the 'set -x' form, you can set it up to trace through just
the interesting parts of your code. (Somewhat counter intuitively 'set
- -x' or 'set -o xtrace' turns on trace mode; 'set +x' or 'set +o xtrace'
turns it off)

This doesn't give you a way of arbitrarily querying the value of any
variable, but you will be able to see all variable assignments as part
of the trace.

There's also a '-v' flag which adds displaying input read by the shell
as it executes.

Cheers,

Matthew

- -- 
Dr Matthew J Seaman MA, D.Phil.   7 Priory Courtyard
  Flat 3
PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate
JID: matt...@infracaninophile.co.uk   Kent, CT11 9PW
-BEGIN PGP SIGNATURE-
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkwDb3EACgkQ8Mjk52CukIyoLwCfdTamyG/PnEgdbWEDlZwaW28B
HCwAn2WhU6/GCLzamityi3YiW79OcjS9
=7vBz
-END PGP SIGNATURE-
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: how to debug .sh type script

2010-05-31 Thread Elias Chrysocheris
On Monday 31 of May 2010 10:59:04 Aiza wrote:
 Is there way to single step through each line of code and see the real
 values of the variables?
 ___
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to
 freebsd-questions-unsubscr...@freebsd.org

I'm not aware of a way to single step a script. But the old method of echo and 
exit is the way I use. I use echo to print the values and the line numbers 
that I want and exit to stop the execution of the script at a point I wish it 
to stop.

Elias
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: how to debug .sh type script

2010-05-31 Thread Jerry
On Mon, 31 May 2010 15:59:04 +0800
Aiza aiz...@comclark.com articulated:

 Is there way to single step through each line of code and see the
 real values of the variables?

You did not indicate what language your script is written in. There are
quite a few sites that have information for debugging a Bash script.

http://bashdb.sourceforge.net/bashdb-man.html
http://www.tldp.org/LDP/abs/html/debugging.html
http://www.softpanorama.org/Scripting/Shellorama/bash_debugging.shtml
http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_02_03.html

There are lots of others. Just Google or Bing for it.

-- 
Jerry
freebsd.u...@seibercom.net

Disclaimer: off-list followups get on-list replies or get ignored.
Please do not ignore the Reply-To header.
__
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org