ksh debugging

  • Follow


Hello,

I have been using "sh -x script_name" to debug shell script (ksh) on
other machine but it looks like this, sh -x, doesn't work properly on
Sun Solaris 9. Can anyone answer me this? What should I use to debug
ksh script on Sun Solaris 9? set -xv?

Thanks

0
Reply kang_uni (8) 4/5/2006 9:35:38 PM

In <1144272938.399255.156650@u72g2000cwu.googlegroups.com> "Herbert" <kang_uni@hotmail.com> writes:

>I have been using "sh -x script_name" to debug shell script (ksh) on
>other machine but it looks like this, sh -x, doesn't work properly on
>Sun Solaris 9. Can anyone answer me this? What should I use to debug
>ksh script on Sun Solaris 9? set -xv?

Have you tried `ksh -x script_name'?  Otherwise, `man ksh' should
tell you what you need to know.



-- 
-Gary Mills-    -Unix Support-    -U of M Academic Computing and Networking-
0
Reply Gary 4/5/2006 10:30:01 PM


Herbert <kang_uni@hotmail.com> wrote:
> Hello,
> 
> I have been using "sh -x script_name" to debug shell script (ksh) on
> other machine but it looks like this, sh -x, doesn't work properly on
> Sun Solaris 9. Can anyone answer me this? What should I use to debug
> ksh script on Sun Solaris 9? set -xv?

If it is a ksh script why don't you call ksh instead of sh:

	ksh -x script_name

Remember: The -x flag is reset on function calls, so you will normally only
be able to trace the "main()" part of your shell script if you invoke it
like above.

-- 
Daniel
0
Reply Daniel 4/5/2006 10:52:18 PM

Gary Mills <mills@cc.umanitoba.ca> writes:

>In <1144272938.399255.156650@u72g2000cwu.googlegroups.com> "Herbert" <kang_uni@hotmail.com> writes:

>>I have been using "sh -x script_name" to debug shell script (ksh) on
>>other machine but it looks like this, sh -x, doesn't work properly on
>>Sun Solaris 9. Can anyone answer me this? What should I use to debug
>>ksh script on Sun Solaris 9? set -xv?

>Have you tried `ksh -x script_name'?  Otherwise, `man ksh' should
>tell you what you need to know.

Take a look at the kshdbx package on the blastwave site:

    http://www.blastwave.org/packages.php/kshdbx

This is my revision to the kshdb script originally published in the book
"Learning the Korn Shell".  It includes a full man page.  Below is the
brief description from that site.  This is distributed in solaris package
format so it is easy to install and uninstall using the blastwave pkg-get
tool.

Regards,
-- 
C. Jeffery Small

---------------------------------------------------------------------------
The kshdbx software package provides a debugger for Korn shell (ksh)
scripts. This package offers the following features:

* Step through the code N lines at a time [default: 1]
* List the source code
* Set breakpoints at line numbers
* Set breakpoints at lines containing a specified string
* Set a conditional breakpoint
* Display the value of variables
* Execute arbitrary shell commands at a breakpoint

This tool is based upon the kshdb scripts originally written by Bill
Rosenblatt and published in January 1993 by O'Reilly & Associates in the
book "Learning the Korn Shell" (ISBN: 1-56592-054-6). These scripts were
subsequently republished in the May 1993 issue of UnixWorld Magazine.
---------------------------------------------------------------------------
0
Reply jeff 4/5/2006 11:54:18 PM

On Wed, 5 Apr 2006, Herbert wrote:

> I have been using "sh -x script_name" to debug shell script (ksh) on

Ummm, why are you using sh to test a ksh script?

> other machine but it looks like this, sh -x, doesn't work properly on
> Sun Solaris 9. Can anyone answer me this? What should I use to debug

Ah.  You probably use Linux, where "sh" is not sh at all, but bash.  THe
latter has facilites that sh does not.

Modulo this, others have posted some good advice on how to debug a ksh
script.

HTH,

-- 
Rich Teer, SCNA, SCSA, OpenSolaris CAB member

President,
Rite Online Inc.

Voice: +1 (250) 979-1638
URL: http://www.rite-group.com/rich
0
Reply Rich 4/6/2006 1:58:35 AM

"Daniel Rock" <v200614@deadcafe.de> wrote:

> Remember: The -x flag is reset on function calls, so you will
> normally only be able to trace the "main()" part of your shell
> script if you invoke it like above.

....
.... getoptc...
....
 -d) DEBUG=true
     ;;
....
if $DEBUG
then
  set -o x
  typeset -ft <function_name_1>
  ...
fi



0
Reply Martin 4/12/2006 11:07:37 PM

5 Replies
809 Views

(page loaded in 0.059 seconds)

Similiar Articles:













7/23/2012 8:36:30 AM


Reply: