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 > UNIX for Dummies Questions & Answers
.
google unix.com



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
Help with AWK -- quick question Probos Shell Programming and Scripting 5 07-18-2007 04:26 PM
quick question keith.m AIX 5 12-21-2006 09:27 AM
quick sed question vbm Shell Programming and Scripting 2 11-09-2006 10:44 PM
quick question pkolishetty UNIX for Dummies Questions & Answers 2 09-02-2006 11:56 AM
Ok quick question Corrail Shell Programming and Scripting 1 11-11-2005 01:49 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-22-2003
catbad catbad is offline
Registered User
  
 

Join Date: Jul 2002
Location: SoFla
Posts: 9
Quick Question

Hello There!
I am trying to write this SIMPLE script in Bourne Shell but I keep on getting syntax errors. Can you see what I am doing wrong? I've done this before but I don't see the difference. I am simply trying to take the day of the week from our system and when the teachers sign on I want them to see the message of the day, when they exe "Schedule" (the name of this script).
Code:
#!/bin/sh
case $day in

 Mon) echo '1st grade please meet in front office conference rm at 2 pm.';;
 Tue) echo 'No school for students';;
 Wed) echo 'Kindegarten, Jane will meet you in Saban's room.';;
 Thu) echo 'Short Faculty meeting in Media Center.';;

 Fri) echo 'Please remind parents to sign in at front office!';;
 Sat) echo 'If you are on VPDN, please be sure to logout';;
 Sun) echo 'Why are you working?, Its Sunday!';;
#
#
esac
added code tags for readability --oombera

Last edited by oombera; 02-19-2004 at 04:17 PM..
  #2 (permalink)  
Old 03-23-2003
oombera's Avatar
oombera oombera is offline Forum Advisor  
Registered User
  
 

Join Date: Aug 2002
Location: Cleveland, OH
Posts: 804
Are you sure you use the words 'Mon' 'Tues' etc and not numbers that represent the day of the week?

1) echo '1st grade ...
2) echo 'No school ...
3) echo 'Kindergarten ...
...
...
  #3 (permalink)  
Old 03-23-2003
catbad catbad is offline
Registered User
  
 

Join Date: Jul 2002
Location: SoFla
Posts: 9
Thanks for your help. I did change the days to numbers Sunday being one since that is the day our system starts. It did get rid of the syntax error BUT now when I run the script....nothing happens. Any additional ideas. My script now looks like this:
Code:
case $day in
 1) echo 'why are you working';;
 2) echo 'comment 2';;
 3) echo 'comment 3.';;
 4) echo 'comment 4/reminder.';;
 5) echo 'comment6.';;
 6) echo 'meetings?';;
 7) echo 'vpdn reminders';;
esac
added code tags for readability --oombera

Last edited by oombera; 02-19-2004 at 04:18 PM..
  #4 (permalink)  
Old 03-23-2003
oombera's Avatar
oombera oombera is offline Forum Advisor  
Registered User
  
 

Join Date: Aug 2002
Location: Cleveland, OH
Posts: 804
Oh wait, $day is the day of the month, which means it'd be equal to 23 today... you want to use the variable $dayweek, where 0 represents Sunday, 1 is Monday, and so on.

Code:
# SHELL VARIABLES:
# ----------------
#
# YEAR    :  Year of the session to be processed (2 digit)
# DAYYEAR :  Julian day of the year
# DAY     :  Day of the Month
# MONTH   :  Month, 1=JAN, 12=DEC
# DAYWEEK :  Day of the week, 0=SUN, 6=SAT
http://www.unavco.ucar.edu/data_supp...k_scripts.html

Last edited by oombera; 03-23-2003 at 02:03 PM..
  #5 (permalink)  
Old 03-23-2003
catbad catbad is offline
Registered User
  
 

Join Date: Jul 2002
Location: SoFla
Posts: 9
Thank you for the link oombera. I do apprecite your help. I changed to dayweek and renumbered but I amstill not getting an outcome. I will do some research on the website you provided.

Thanks
  #6 (permalink)  
Old 03-24-2003
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
I don't understand why you guys think that variables like WEEKDAY are set automatically. Even if that is true, $WEEKDAY and $weekday are two different variables.

Do something like this:
echo WEEKDAY = $WEEKDAY
to see if WEEKDAY is really set automatically in your environment. But I'm betting that it is just empty.

If you want to set a variable to the day of the week, do something like this:
weekday=`date +%u`
  #7 (permalink)  
Old 03-24-2003
oombera's Avatar
oombera oombera is offline Forum Advisor  
Registered User
  
 

Join Date: Aug 2002
Location: Cleveland, OH
Posts: 804
oops lol - magic variables that just know what you'd like them to contain and then set themselves

looks like s93366 got it right in the other thread.
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 06:27 AM.


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