LinuxQuestions.org
Register a domain and help support LQ
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 09-19-2012, 07:17 AM   #1
Salem
LQ Newbie
 
Registered: Sep 2012
Posts: 11

Rep: Reputation: Disabled
Exclamation Reminder Command


Hello everyone,

I have something wrong with this command
i don,t know what is the problem
can someone help me please

Code:
! /bin/sh
Start your code from here
!/bin/bash
Define Files and dates
EventMemberFile="./Event-member.data"
ReminderFile="./Reminder.email"
currentMonth=`date +"%m"`
currentDay=`date +"%d"`

read the event member files line by line
OLDIFS=$IFS
IFS=','
while read EventTitle FirstName LastName MeetingMonth MeetingDay EmailAddress
do
avoid comments
[[ "$EventTitle" = \#* ]] && continue 
compare dates change parameters and send emails

if [[ "$MeetingMonth" == "$currentMonth" ]] ;  
  then
	sed -e 's/__FULLNAME__/'$FirstName' '$LastName'/g' -e 's/__Project__/'$EventTitle'/g' $ReminderFile 


	#sed -e 's/__FULLNAME__/'$FirstName' '$LastName'/g' -e 's/__Project__/'$EventTitle'/g' $ReminderFile | mail -s "meeting reminder""alzaabi.slm@gmail.com"

else echo "Ignoring" $EventTitle "because it's not today" ;
fi
echo $EventTitle $FirstName $LastName $MeetingMonth $MeetingDay $EmailAddress



done < $EventMemberFile

IFS=$OLDIFS
exit 0
 
Old 09-19-2012, 07:30 AM   #2
cortman
Member
 
Registered: Jan 2012
Location: ZZ9 Plural Z Alpha
Distribution: Crunchbang 11, LFS 7.3, DSL 4.1.10, Lubuntu 12.10, Debian 7
Posts: 219

Rep: Reputation: 43
You didn't quote out your comments, for one-

Code:
# Start your code from here
 
Old 09-19-2012, 07:45 AM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
A script typically starts with something like this---to tell the shell what to use to run the script:
#!/bin/bash

Also, you need to format your code for readability (by us---and by YOU)---example:
Code:
while read <stuff>; do
     if <something>; then
          <do stuff>
     else
          <do different stuff>
     fi
     <more stuff>
done
finally, I'm not sure this is legal:
Code:
while read EventTitle FirstName LastName MeetingMonth MeetingDay EmailAddress
What is the intent here?

Last edited by pixellany; 09-19-2012 at 07:48 AM.
 
Old 09-19-2012, 07:51 AM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
PS---Tell us exactly what happens when you run the script. Just saying "something is wrong" does not give us any clues.
 
Old 09-19-2012, 01:04 PM   #5
Salem
LQ Newbie
 
Registered: Sep 2012
Posts: 11

Original Poster
Rep: Reputation: Disabled
Question

Quote:
Originally Posted by pixellany View Post
PS---Tell us exactly what happens when you run the script. Just saying "something is wrong" does not give us any clues.
thank you for your reply

this is the error
Code:
./MeetingReminder.sh: line 3: !/bin/bash: No such file or directory
./MeetingReminder.sh: line 4: Define: command not found
 
Old 09-19-2012, 01:14 PM   #6
Habitual
Senior Member
 
Registered: Jan 2011
Distribution: Undecided
Posts: 3,335
Blog Entries: 5

Rep: Reputation: 785Reputation: 785Reputation: 785Reputation: 785Reputation: 785Reputation: 785Reputation: 785
terminal >
Code:
which $SHELL
output please.
 
Old 09-20-2012, 09:02 AM   #7
cortman
Member
 
Registered: Jan 2012
Location: ZZ9 Plural Z Alpha
Distribution: Crunchbang 11, LFS 7.3, DSL 4.1.10, Lubuntu 12.10, Debian 7
Posts: 219

Rep: Reputation: 43
Quote:
Originally Posted by Salem View Post
thank you for your reply

this is the error
Code:
./MeetingReminder.sh: line 3: !/bin/bash: No such file or directory
./MeetingReminder.sh: line 4: Define: command not found
You need to put a hash mark # in front of !/bin/sh:

Code:
#!/bin/sh
And you need hash marks in front of anything that isn't code, just as I said earlier.
 
Old 09-20-2012, 12:28 PM   #8
suicidaleggroll
Senior Member
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 2,839

Rep: Reputation: 1006Reputation: 1006Reputation: 1006Reputation: 1006Reputation: 1006Reputation: 1006Reputation: 1006Reputation: 1006
Are you trying to run this with sh or bash?

You have "! /bin/sh" at the top, which while it's the wrong syntax, implies you want to run the script in sh, then two lines later you have "!/bin/bash", which again is the wrong syntax, but implies you want to run the script in bash. Pick one, change it to #!/bin/sh or #!/bin/bash, delete the other, and put a # in front of all comment lines.
 
Old 09-23-2012, 04:48 AM   #9
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
I highly suggest that the OP sit down with a good scripting tutorial and start working through it. Don't try writing complex scripts until you're at least reasonably familiar with the basics of the syntax.

It also goes without saying that you shouldn't just cut&paste code from the net without understanding what it does.


I recommend the BashGuide and linuxcommand as good starting points. Also have a look at the other links below for commonly-made errors and situational how-tos.

http://mywiki.wooledge.org/BashGuide
http://www.linuxcommand.org/index.php

http://mywiki.wooledge.org/BashPitfalls
http://wiki.bash-hackers.org/scripting/newbie_traps
http://mywiki.wooledge.org/BashFAQ


Quote:
Originally Posted by pixellany View Post
finally, I'm not sure this is legal:
Code:
while read EventTitle FirstName LastName MeetingMonth MeetingDay EmailAddress
What is the intent here?
For the record, this is perfectly legal syntax. read will store one word from the input line (as defined by IFS) in each variable supplied to it, with any additional text going into the final one.

You could also similarly use the -a option (assuming bash or similar); only then the words are stored in an array instead.
 
Old 09-23-2012, 05:03 AM   #10
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
By the way, there are already many good "reminder" style programs out there. Is there any special reason why you want to script this?
 
Old 09-23-2012, 05:42 AM   #11
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,245
Blog Entries: 15

Rep: Reputation: 233Reputation: 233Reputation: 233
Reminds of the Slackware quotes. If you could place reminders instead..
I don't have Slackware yet though so I can't examine. It probably has something to do with the post-login scripts in bash.
 
  


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
Simple Reminder jereece Linux - Software 1 07-07-2010 06:25 PM
[SOLVED] Reminder using cron MTK358 Linux - General 7 04-20-2010 01:36 PM
Reminder application General Linux - Software 1 05-14-2006 03:19 AM
LQ ISO Reminder jeremy LQ Suggestions & Feedback 6 03-06-2005 12:52 PM
ad reminder jeremy LQ Suggestions & Feedback 8 01-09-2003 03:02 PM


All times are GMT -5. The time now is 03:59 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration