|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I have a script that is a while loop that searches for a condition.
it then sends a email to let me know of the condition, but the script checks for the condition every 5 minutes and sends me a email every 5 minutes. How do I just send me one email untill the condition exists again? |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
killerlou@gmail.com wrote:
> I have a script that is a while loop that searches for a condition. > it then sends a email to let me know of the condition, but the script > checks for the condition every 5 minutes and sends me a email every 5 > minutes. How do I just send me one email untill the condition exists > again? > Your description is very vague. Depending on your condition... while : do condition && mail -s "condition got true" < mail_body sleep 300 done Janis |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Sorry Janis,
I'll be plain. I have a script that looks at craigslist every 5 minutes and sees if there are free items in my location. It will find that there is one and sends me a email, but it could be minutes or hours before there is a new posting and what happens is that the script sends me a email every 5 minutes. I want it to know it sent me a email and not send another untill there is a new posting for my area. It would have to know it was a new one not the same one. Thats what I'm working on. If you can , Thanks. Janis Papanagnou wrote: > killerlou@gmail.com wrote: > > I have a script that is a while loop that searches for a condition. > > it then sends a email to let me know of the condition, but the script > > checks for the condition every 5 minutes and sends me a email every 5 > > minutes. How do I just send me one email untill the condition exists > > again? > > > > Your description is very vague. Depending on your condition... > > while : > do > condition && mail -s "condition got true" < mail_body > sleep 300 > done > > > Janis |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
killerlou@gmail.com wrote:
[ Please don't top-post. ] > Sorry Janis, > > I'll be plain. > > I have a script that looks at craigslist every 5 minutes and sees if > there are free items in my location. It will find that there is one > and sends me a email, but it could be minutes or hours before there is > a new posting and what happens is that the script sends me a email > every 5 minutes. I want it to know it sent me a email and not send > another untill there is a new posting for my area. It would have to > know it was a new one not the same one. > > Thats what I'm working on. > > If you can , Thanks. I don't know what "craigslists" are; I'd have expected that you would explain the task in terms of the OS entities, files, data formats, and the _concrete condition_ that I asked for in technical terms. What are the concrete "items" you talk of, how is "in my location" defined, a working directory, a filesystem? The script below is complete in this respect; you just have to fill in the condition part, or, tell about how the condition can be derived and we can show you working solutions. For example; 'condition' may be a 'grep -s' command, or a test to check for the existance of a file '[ -f ... ]', or a command to check for a file that is newer than another file 'find -newer', etc. Janis > > > > Janis Papanagnou wrote: > >>killerlou@gmail.com wrote: >> >>>I have a script that is a while loop that searches for a condition. >>>it then sends a email to let me know of the condition, but the script >>>checks for the condition every 5 minutes and sends me a email every 5 >>>minutes. How do I just send me one email untill the condition exists >>>again? >>> >> >>Your description is very vague. Depending on your condition... >> >> while : >> do >> condition && mail -s "condition got true" < mail_body >> sleep 300 >> done >> >> >>Janis > > |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
In news:1177695439.880365.226560@s33g2000prh.googlegr oups.com,
killerlou@gmail.com <killerlou@gmail.com> wrote: > I have a script that looks at craigslist every 5 minutes and sees if > there are free items in my location. It will find that there is one > and sends me a email, but it could be minutes or hours before there is > a new posting and what happens is that the script sends me a email > every 5 minutes. I want it to know it sent me a email and not send > another untill there is a new posting for my area. It would have to > know it was a new one not the same one. > > Thats what I'm working on. If your crond supports such a crontab syntax, then: */5 * * * * /home/you/scripts/craigslist.check and your craigslist.check script might read: #!/usr/bin/env bash URL=http://phoenix.craigslist.org/zip/ address="you@some.where,sombebody_else@somewhere.e lse" new=/tmp/newfile old=/tmp/oldfile lynx -dump $URL | grep -v \ "\[ $(date '+%a, %d %b')" \ > $new 2>/dev/null if [ ! -f $old ] ; then \cp $new $old fi if [ x"$(diff $new $old | sed -e 's/\"//g')" != x"" ] ; then echo "New items listed on $URL" | \ mail -s "new free items" "$address" \cp $new $old fi # end script |
|
![]() |
| Outils de la discussion | |
|
|