UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old December 6th, 2004, 10:51 PM
vinnie48 vinnie48 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Location: Az
Posts: 4 vinnie48 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
can`t get this script to write

#

hour=`date +%H`H # store the part of the date string that shows the hour

if [ "$hour"‑le 12 ] # check for the morning hours

then

echo "GOOD MORNING"

elif [ "$hour" ‑le 18 ] # check for the afternoon hours

then

echo "GOOD AFTERNOON"

else

echo "GOOD EVENING"

fi

$_

Reply With Quote
  #2  
Old December 7th, 2004, 01:52 AM
zlutovsky zlutovsky is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Location: Prague, Czech Rep.
Posts: 116 zlutovsky User rank is Corporal (100 - 500 Reputation Level)zlutovsky User rank is Corporal (100 - 500 Reputation Level)zlutovsky User rank is Corporal (100 - 500 Reputation Level)zlutovsky User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 22 h 34 sec
Reputation Power: 6
Winie,

1. leave the ending H from the command

hour=`date +%H`H

2. Surround each '-le' in test commands with spaces on both sides

3. you need not use quotation marks in your tests like

if [ "$hour"‑le 12 ]

in this case, but you can.

Regards

Reply With Quote
  #3  
Old December 12th, 2004, 05:28 AM
guggach guggach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,077 guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 13 h 40 m 11 sec
Reputation Power: 8
if-else-fi are beautifull, other tools better, try:
#!/bin/sh
case `date +%H` in 19¦2? ) x=EVENING ;; 1[3-8] ) x=AFTERNOON ;; esac
echo GOOD ${x:-MORING}
exit 0 # needless here, but a good practice

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > can`t get this script to write


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

IBM developerWorks




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway