![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| ksh scripting help | praveenbvarrier | Shell Programming and Scripting | 1 | 04-15-2008 10:19 AM |
| sql scripting help | sam786 | Shell Programming and Scripting | 3 | 12-10-2007 12:31 PM |
| difference between AIX shell scripting and Unix shell scripting. | haroonec | Shell Programming and Scripting | 2 | 04-12-2006 08:12 AM |
| scripting guru's pls help me with scripting on AIX | thatiprashant | Shell Programming and Scripting | 1 | 01-20-2006 07:58 PM |
| Scripting? | woofie | What's on Your Mind? | 1 | 03-09-2005 07:03 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Scripting help
Hi,
I have an assignment for my Unix class to write a program asking a user to enter a number. the user then chooses an option from a menu of whether they want to count down to zero from the number they entered, or count up from zero to the number. The error i keep getting is binary operator expected for lines 9 and 14 , than when i change that it says unary operator expected. Also I want to know if I coded this whole thing corretly. any ideas? Code:
echo "Enter a number" read $number echo "What do you want to do to this number?" echo "Enter d, to count down to zero" echo "Enter u, to count up from zero" read choice case $choice in d) while [ "$number" \>= "0" ] do echo $number $number = `expr $number - 1` done;; u) while [ "0" \<= "$number" ] do echo $number $number = `expr $number + 1` done;; esac echo "bye" ~ |
|
||||
|
Hi, Thank you Smiling Dragon. i fixed the problems with not having the dollar sign in front of the choice variable. however, now i can run the script and I get no errors, but nothing outputs except the "bye" at the end. I know you cant give me the answer, but would you know how to point in the right direction?
|
|
|||||
|
As Smiling Dragon mentioned it's against the forum's rules posting homework..., but at least you have put some effort:
Code:
echo "Enter a number" read number echo "What do you want to do to this number?" echo "Enter d, to count down to zero" echo "Enter u, to count up from zero" read choice case $choice in d) while [ "$number" -ge 0 ] do echo $number number=`expr $number - 1` # no spaces here before/after = sign done;; u) while [ 0 -le "$number" ] do echo $number number=`expr $number + 1` done;; esac echo "bye" ~ Last edited by rubin; 05-14-2008 at 07:59 PM.. Reason: removed extra $$ |
|
||||
|
Thank you both SO much for your help!!!
|
| Sponsored Links | ||
|
|