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 > perl or shell script for ip manipulation
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

perl or shell script for ip manipulation

Réponse
 
LinkBack Outils de la discussion
Vieux 22/12/2007, 05h46   #1
Dave
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut perl or shell script for ip manipulation

Hello,
I'm wanting to develope a script for ip change notification. Since my
box doesn't change cleanly, i'd like to run this script from cron say every
30 minutes. First thing it does is checks the IP, if it's the same as 30
minutes ago it pings one of about ten sites from a list in random order. If
that works, everything is well exit. If not meaning the ip test reports the
same as 30 minutes ago but pinging that list returns nothing then run three
commands, obtain the new ip, save it, and send an email to a designated
address.
I'm not sure if i should do this in shell or perl, as of right now i
have the ip address printing, but i believe i'd have to do something with
saving state between script loads, this i've never done. If anyone has any
suggestions i'd appreciate them.
Thanks.
Dave.


  Réponse avec citation
Vieux 23/12/2007, 07h52   #2
Barry Margolin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: perl or shell script for ip manipulation

In article <476ca4c0$0$32506$4c368faf@roadrunner.com>,
"Dave" <dmehler26@woh.rr.com> wrote:

> Hello,
> I'm wanting to develope a script for ip change notification. Since my
> box doesn't change cleanly, i'd like to run this script from cron say every
> 30 minutes. First thing it does is checks the IP, if it's the same as 30
> minutes ago it pings one of about ten sites from a list in random order. If
> that works, everything is well exit. If not meaning the ip test reports the
> same as 30 minutes ago but pinging that list returns nothing then run three
> commands, obtain the new ip, save it, and send an email to a designated
> address.
> I'm not sure if i should do this in shell or perl, as of right now i
> have the ip address printing, but i believe i'd have to do something with
> saving state between script loads, this i've never done. If anyone has any
> suggestions i'd appreciate them.
> Thanks.
> Dave.


Write the state to a file, and read it back in the next time you run.
If you do it in shell, a simple way to implement this would be to format
the file as a bunch of variable assignments; use ". filename" to execute
the file, and the variables will be assigned those values. In Perl you
could use a hash. Write a sequence of VARIABLE <space> VALUE lines to
the file, and then read it back in with a loop that uses VARIABLE as the
key in the hash.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
  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 09h52.


É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,10511 seconds with 10 queries