LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-26-2001, 10:25 AM   #1
msj
LQ Newbie
 
Registered: Aug 2001
Location: Canada
Posts: 3

Rep: Reputation: 0
Unhappy small script


I am trying to write a small script that would
first say hi from 6am to 12 pm and say Good afternood from
1pm to 5pm. I know we use if but it seems I'm doing something wrong.

if $date "+%T" -ge 6 -a le 12
then
echo "Good morning"
fi

if $date "+%T" -ge 1 -a le 5
then
echo "Good afternoon"
fi

Please tell me what's wrong in there, I can't find it.

Thanks
 
Old 08-26-2001, 11:42 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
You're not using 'test' to actually evaulate your code. the conditoin checking should be encased in square brackets [ ] OR be chaged to `test .... ` Remember that shell programming is not one large programming langauge, but a collection of individual programs which rely on useful outputs from others...

try this...

-------------
HOUR=`date '+%H'`

if [ $HOUR -ge 18 ]
then
echo Good Evening
exit
fi

if [ $HOUR -ge 12 ]
then
echo Good Afternoon
exit
fi

if [ $HOUR -ge 6 ]
then
echo Good Morning
exit
fi

echo Criminy!! What are you doing up at this time?!!
--------

Any Help? I'm not very good at shell script, but i had nothign else to do at work.... ;-)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
small script Kassel Programming 2 11-19-2004 04:22 AM
help with a very small script hamish Linux - General 3 06-09-2004 02:10 AM
Need help with very small script. Franklin Programming 8 10-14-2003 12:37 PM
Please Help with a small script ? juglugs Programming 2 11-14-2001 02:39 AM
Small Script msj Linux - Newbie 2 08-27-2001 06:59 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration