Visit Our UNIX and Linux User Community


run in debug mode


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting run in debug mode
# 1  
Old 10-21-2004
Question 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,
Smilie
# 2  
Old 10-22-2004
I guess this definitively shouldn't happen. Did you test with another bourne shell?
# 3  
Old 10-22-2004
How are you executing your program and What do you have as the first line in your script? Example: #!/bin/ksh

Last edited by google; 10-22-2004 at 01:37 AM..
# 4  
Old 10-22-2004
Tools #! /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.
# 5  
Old 10-22-2004
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.
# 6  
Old 10-22-2004
Question |bc or scale=1?

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

?
# 7  
Old 10-22-2004
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)

Previous Thread | Next Thread
Test Your Knowledge in Computers #575
Difficulty: Medium
If a program has poor memory management and fails to deallocate memory when it is no longer needed, the memory will not leak.
True or False?

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Logging perl and shell debug mode.

I have a shell program which calls a perl program. I am running the shell program with command; $ ksh -x <prog_name> Inside the shell program, I am calling perl with warnings. I want to capture the entire output as it comes on screen. The command I tried is: $ ksh -x... (1 Reply)
Discussion started by: som.nitk
1 Replies

2. Programming

Is there any possibility of running the PHP script in a debug mode ?

Is there any possibility of running the PHP script in a debug mode ? If so, do i have to download any package? Any free downloads available? Can anyone please guide me through? Am a newbie in PHP scripting. Thanks in Advance! (1 Reply)
Discussion started by: vidhyaS
1 Replies

3. Shell Programming and Scripting

perl: a way to see a sub code in debug mode: perl -de 0 ?

Is there a way to see or print a sub code? Sometime a sub could be already defined, but in the debug mode (so, interactively) it could be already out of screen. So, I would think about a way to check if the sub is defined (just 'defined' is not a problem) and how it is defined. Also, if... (4 Replies)
Discussion started by: alex_5161
4 Replies

4. Programming

Compile a proc/c++ file in debug mode.

Hi, I'm using the following commands to execute a proc file, but I'm unable to debug the program. What modifications do I need to make in the command options to debug the program created. I have a proc1.pc file, using the following three steps to generate the proc1 exe. After the proc1 exe... (2 Replies)
Discussion started by: ehari
2 Replies

5. Red Hat

ehternet in debug mode

I have a little dell running redhat server. it's getting ethernet traffic to console and /var/log/messages (up 60Mb) i can't seem to find where to turn it off! any help would be greatly appreciated. here's syslog: here's a snip from the log: Sep 28 21:34:08 zgarch_serv kernel: IN=eth0... (2 Replies)
Discussion started by: toferloafer
2 Replies

6. AIX

Running Installp in debug mode

Is there a way I can execute an installp command in debug mode, so that I can see whats happening when a fileset is being installed or updated? (What files are being replace etc etc). I have an installp command failing for unknown reason. (7 Replies)
Discussion started by: balaji_prk
7 Replies

7. Shell Programming and Scripting

Debug mode

When I run a lengthy script in debug mode i need to capture all the steps which are executed. e.g ksh -x script.ksh + test -f /proc/mounts + /bin/ls -l /proc/21326/exe + is=ksh + test ksh = ksh + test -s /etc/ksh.kshrc + . /etc/ksh.kshrc + trap 1 2 3 + who am i + awk {print $1} +... (2 Replies)
Discussion started by: zooby
2 Replies

8. UNIX for Advanced & Expert Users

“Ostream” object is not printing message on HP-UNIX for debug mode

The following C++ code segment is not working in debug mode build on HP-UNIX machine. It is not printing "Hello World" message on the screen. While it is working fine in release mode build. ============================================== class KLogStreamBuf : public streambuf { public:... (0 Replies)
Discussion started by: heena
0 Replies

Featured Tech Videos