PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > Script to send one email until the condition exists again.
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

Script to send one email until the condition exists again.

Réponse
 
LinkBack Outils de la discussion
Vieux 27/04/2007, 01h38   #1
killerlou@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Script to send one email until the condition exists again.

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?

  Réponse avec citation
Vieux 27/04/2007, 02h30   #2
Janis Papanagnou
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Script to send one email until the condition exists again.

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
  Réponse avec citation
Vieux 27/04/2007, 19h37   #3
killerlou@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Script to send one email until the condition exists again.

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


  Réponse avec citation
Vieux 28/04/2007, 01h35   #4
Janis Papanagnou
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Script to send one email until the condition exists again.

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

>
>

  Réponse avec citation
Vieux 28/04/2007, 22h36   #5
Patrick
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Script to send one email until the condition exists again.

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


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 22h51.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,12711 seconds with 13 queries