automated shell script



Hi,

Can any one help me out in writing a shell script as i am new to
scripting.

The requirement is that i want to check for paticular file names
whether they exist or not in a directory and then if it exists, then it
should mail to a person the file names, else if it does not exist, then
it should mail to another person saying that 'file name does not exist.
Added to this it should check for different file names on different
weekdays.

eg:

if it is monday, check for file_1.txt and file_2.txt in a directory
and if exist ,mail the file names to a person.(the file name is
recognised by a sysdate on it) else mail to another person.

if it is tuesday, check for filname_3.txt and filename4.txt ........
....

I tried to write the script, and this is what i have done so far(built
the concept but with no syntax)

###using today
DAY1=`TZ=GMT+6 /usr/bin/date +%Y%m%d`
echo $DAY1

# using today - 1 (yesterday's date) in YYMMDD format
DAY2=`TZ=GMT+30 /usr/bin/date +%Y%m%d`
export YYYYMMDD
echo $YYYYMMDD

Today = F$cvtime("today",,"weekday")
if today .eqs. "Monday" then goto monday
if today .eqs. "Tuesday" then goto tuesday
if today .eqs. "Wednesday" then goto wednesday
if today .eqs. "Thursday" then goto thursday
if today .eqs. "Friday" then goto friday
go to weekend
Monday:
if [ -e filename.txt ]
then
such and such
fi

exit
Tuesday:
......
...
exit

Wednesday:
.....
exit
Thursday:

exit
Friday:

exit
Weekend:

exit


Is this concept correct by any means.

Thanks,
Sapna

.



Relevant Pages

  • Re: automated shell script
    ... Can any one help me out in writing a shell script as i am new to ... if today .eqs. ... "Tuesday" then goto tuesday ...
    (comp.unix.shell)
  • Re: automated shell script
    ... echo $i Found || echo $i Not Found; ... if today .eqs. ... "Tuesday" then goto tuesday ...
    (comp.unix.shell)
  • Re: Stop execution of script
    ... If you are using Wise, I would move the decision logic whether to run the ... script or not to the Wise script if possible, and design your SQL scripts to ... >>> A GOTO statement references the label 'EXIT' but the label has not been ...
    (microsoft.public.sqlserver.programming)
  • Re: Reintroducing fish, the friendly interactive shell
    ... echo>&2 ERROR; ... That exits the script, not the current function. ... (yes I know, I could have written it otherwise or with a goto, ...
    (comp.unix.shell)
  • Re: Is David Fenton right about error handling? (re-post?)
    ... > Error Goto 0 a proper termination. ... after the Exit Function. ... Clears all property settings of the Err object. ... Exit Sub, Exit Function, Exit Property ...
    (comp.databases.ms-access)