run in debug mode

Hi,
I have a question on my korn shell script.
When I run without debugging turned on, I can't get the correct result. If I turn on the debug mode, like sh -x myprogram, it will give me the correct result.

Can someone tell me what is going on here?

Thanks,
:rolleyes:

I guess this definitively shouldn't happen. Did you test with another bourne shell?

How are you executing your program and What do you have as the first line in your script? Example: #!/bin/ksh

Yes. I have #! /bin/ksh at the begining of my program.

It's very interesting that I only get correct result when I run it with sh -x myprogram mode.

It will give me this message:

=========================
reaktime3[109]: 1690: not found
breaktime3[109]: 900: not found
breaktime3[109]: 1797: not found
breaktime3[109]: 1791: not found

This is my 109 line:

109 /usr/ucb/echo "$intID" "$strNAME" "$intSHIFT" "`$intTotalPaidBreak|bc`" "$intTotalUnpaidBreak" >>/tmp/breaktime/REPORT.$$

=========================================

It's one line in shell.

Realize that when you specify sh -x on the command line to execute your program, you are asking to run your script with the Bourne (sh) shell. However, the first line of your program specifies to run your script using the Korn (ksh) shell.

Why have you quoted each element individually? You dont need to do that. Use a single set of double quotes around the entire line.

/usr/ucb/echo "$intID $strNAME $intSHIFT
$($intTotalPaidBreak|bc) $intTotalUnpaidBreak"
>>/tmp/breaktime/REPORT.$$

Also, try removing the space in your "magic number". Change #! /bin/ksh to #!/bin/ksh. While the syntax you are using for this should work, and is correct, not all systems support that method any longer. The HP system that I use at work doesnt like the space.

Execute your file after making the changes.

Also, below your #!/bin/ksh line, add the following line:
set -x
This will turn on debugging. You can now execute the shell without specifying ksh -x on the command line.

Thanks Google!
I tried to delete the space between #!/bin/ksh. It didn't make difference.

Could this be the problem with my |bc?
I actually need to set up scale =1 and devide $intTotalPaidBreak/60

$intTotalPaidBreak/60|bc

?

You can always narrow down the issue by removing the variable that contains the bc command. If you dont get an error then that pretty well identifies that the variable is the issue.

Try this:

$(echo "scale=1; $intTotalPaidBreak/60" | bc)