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
Catching all Exit Codes Sivaswami J Shell Programming and Scripting 3 02-16-2006 07:13 PM
Awk- catching the last two chars Gerry405 UNIX for Dummies Questions & Answers 9 11-22-2005 06:23 AM
Catching signal and piping joseph_ng High Level Programming 7 11-14-2005 11:04 AM
catching interrupts toughguy2handle UNIX for Dummies Questions & Answers 1 09-19-2005 03:17 PM
catching all signals in a single handler xtrix High Level Programming 3 12-09-2004 11:10 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-29-2006
bebop1111116 bebop1111116 is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 30
catching some errors

I need to find a way to keep a running tally of how many times events or actions occur. Say if a user is prompted to make inputs of 1 or 2, I want it to keep track of how many times 1 was entered, and how many times 2 was entered.

Thanks for your help

Last edited by bebop1111116; 09-29-2006 at 06:59 PM..
  #2 (permalink)  
Old 09-29-2006
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,422
so have you written anything..?
  #3 (permalink)  
Old 09-29-2006
bebop1111116 bebop1111116 is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 30
yes sir, i have it written until the end where i want it to display the results of how well the user did. now i need to go back through and take care of those possiable errors
  #4 (permalink)  
Old 09-29-2006
mdhmi mdhmi is offline
Registered User
  
 

Join Date: Sep 2006
Location: Detroit, Michigan
Posts: 23
Post the code you've written so far and we'll point you in the right direction. We will -NOT- however do your entire homework assignment.
  #5 (permalink)  
Old 09-29-2006
bebop1111116 bebop1111116 is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 30
I have all of the other errors fixed, but i still need to check that runny tally thing.

Last edited by bebop1111116; 09-29-2006 at 07:00 PM..
  #6 (permalink)  
Old 09-29-2006
Glenn Arndt's Avatar
Glenn Arndt Glenn Arndt is offline Forum Advisor  
Anomalous Lurker
  
 

Join Date: Feb 2006
Location: Indianapolis, IN
Posts: 255
Can you use ksh instead of sh? If so, you can easily test the answers with something like:
Code:
#!/bin/ksh

...possible code...

# Declare inputs as integers
integer n1=0 n2=0

...possible code...

# Take n1 input
until (( $n1 > 0 && $n1 < 21 )); do
  print -n "Please enter a positive integer between 1 and 20: "; read n1
  if (( $n1 < 0 || $n1 > 20 )); then
    print "$n1 is out of range."
  fi
done

# Take n2 input
until (( $n2 > 0 && $n2 < 21 )); do
  print -n "Please enter another positive integer between 1 and 20: "; read n2
  if (( $n2 < 0 || $n2 > 20 )); then
    print "$n2 is out of range."
  fi
done
If you want to display results and quit when the user hits Ctrl-C, you'll need to trap that signal. The syntax is
Code:
trap command signal1 signal2 ...
In your case, the signal would be INT.
Sponsored Links
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 03:49 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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