Previous in Forum: Basic Shell / Bash Programming Linux / Unix   Next in Forum: Unlocking Phone Security
Close
Close
Close
5 comments
Rate Comments: Nested
Member

Join Date: Feb 2013
Posts: 8

Linux and Unix

03/15/2013 6:16 PM

this is my script


#!/bin/bash

echo " please type a number for a month" read monthecho " please type a number for a year" if [ "$month" = "1 - 12" ]
then
cal "$month" 2012 sleep 2 echo " thank you, good bye... "else echo " sorry " sleep 2

fi

I want to prevent the error of showing if you typed a a number higher than 12 to say so "Sorry" but if you type a correct month to say " thank you good bye"

Register to Reply
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.
Guru

Join Date: Jul 2008
Posts: 1688
Good Answers: 145
#1

Re: Linux and Unix

03/15/2013 7:08 PM

I don't know the answer without opening up my Bash book but I do have two comments:

1) If this is homework then CR4 is not a homework cheat site. You have done most of your work and are stuck on a very specific question so if this is homework then you are in more of a "gray" area than a "cheat" area. Whenever a question seems like homework many CR4 members are less likely to help.

2) If this is not homework then I suggest using Perl. You already have Perl on your Linux/Unix box. You can do more complex things more easily in Perl. You can also call Perl scripts from cron and most any other area where you would be tempted to use a Bash scrip.

__________________
Few things limit our potential as much as knowing answers and setting aside questions.
Register to Reply
Member

Join Date: Feb 2013
Posts: 8
#2

Re: Linux and Unix

03/15/2013 7:24 PM

I got all my script done but Im just stuck with this problem for over 1 day trying to figured out...

Register to Reply
Power-User

Join Date: Feb 2011
Location: New Zealand
Posts: 128
Good Answers: 5
#3
In reply to #2

Re: Linux and Unix

03/16/2013 11:13 PM

If you expect to fix all your bugs in a day you are dreaming. Work on it till you solve it.

Register to Reply
Power-User

Join Date: Jan 2006
Location: Worthington Northern Ontario Canada.
Posts: 101
#4

Re: Linux and Unix

03/17/2013 1:55 AM

It looks like you joined CR4 at feb 2013,

Register to Reply
Guru

Join Date: Apr 2010
Location: About 4000 miles from the center of the earth (+/-100 mi)
Posts: 9910
Good Answers: 1141
#5

Re: Linux and Unix

03/17/2013 8:21 AM

monthecho

You words are run together. I don't know if that's due to cut and paste, but if your script is that way the parser can't understand it.

Register to Reply
Register to Reply 5 comments
Copy to Clipboard

Users who posted comments:

BruceFlorida (1); cristianhernandez (1); Jens (1); Oraka (1); Rixter (1)

Previous in Forum: Basic Shell / Bash Programming Linux / Unix   Next in Forum: Unlocking Phone Security

Advertisement