The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to debug a C++ code ahjiefreak High Level Programming 0 04-06-2008 10:46 AM
debug aix 4.3 itik AIX 2 10-29-2007 11:56 AM
how to debug ramneek High Level Programming 1 09-19-2005 06:35 AM
How to debug a C program? whatisthis High Level Programming 1 09-12-2005 09:33 PM
“Ostream” object is not printing message on HP-UNIX for debug mode heena UNIX for Advanced & Expert Users 0 09-13-2004 05:08 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-21-2004
whatisthis's Avatar
whatisthis whatisthis is offline
Registered User
  
 

Join Date: Aug 2004
Posts: 175
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,
  #2 (permalink)  
Old 10-21-2004
AbEnd AbEnd is offline
Registered User
  
 

Join Date: Sep 2003
Location: Canada
Posts: 56
I guess this definitively shouldn't happen. Did you test with another bourne shell?
  #3 (permalink)  
Old 10-21-2004
google's Avatar
google google is offline Forum Advisor  
Moderator
  
 

Join Date: Jul 2002
Location: Atlanta
Posts: 740
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-21-2004 at 11:37 PM..
  #4 (permalink)  
Old 10-22-2004
whatisthis's Avatar
whatisthis whatisthis is offline
Registered User
  
 

Join Date: Aug 2004
Posts: 175
Cool #! /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 (permalink)  
Old 10-22-2004
google's Avatar
google google is offline Forum Advisor  
Moderator
  
 

Join Date: Jul 2002
Location: Atlanta
Posts: 740
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 (permalink)  
Old 10-22-2004
whatisthis's Avatar
whatisthis whatisthis is offline
Registered User
  
 

Join Date: Aug 2004
Posts: 175
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 (permalink)  
Old 10-22-2004
google's Avatar
google google is offline Forum Advisor  
Moderator
  
 

Join Date: Jul 2002
Location: Atlanta
Posts: 740
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)
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:16 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0