Précédent   Forum des professionnels en informatique > Systèmes > Linux > Applications > Shell
Shell Vos questions sur l'utilisation des commandes shell
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 19/07/2007, 15h42   #1
Membre habitué
 
Avatar de arnaud036
 
Inscription : juillet 2007
Messages : 199
Détails du profil
Informations forums :
Inscription : juillet 2007
Messages : 199
Points : 120
Points : 120
Par défaut Déclenchement d'un script lors de l'apparition d'un nouveau fichier

Salut tous le monde,

Je travail sur un serveur de Fax (Hylafax), et je voulais savoir si c'est possible comment je pourrai faire pour executer un traitement (Lancement d'un OCR sur un fax) lorsqu'un nouveau fax arrive.

Merci

arnaud036 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 19/07/2007, 16h51   #2
Modérateur
 
Avatar de ggnore
 
Inscription : juillet 2004
Messages : 2 246
Détails du profil
Informations personnelles :
Âge : 33

Informations forums :
Inscription : juillet 2004
Messages : 2 246
Points : 1 903
Points : 1 903
Après une rapide recherche sur internet, je te conseille de chercher du côté d'inotify.
__________________
Toutes les vertus des hommes se perdent dans l’intérêt comme les fleuves se perdent dans la mer.
ggnore est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/07/2007, 09h52   #3
Membre habitué
 
Avatar de arnaud036
 
Inscription : juillet 2007
Messages : 199
Détails du profil
Informations forums :
Inscription : juillet 2007
Messages : 199
Points : 120
Points : 120
Merci je vais allez voir comment sa fonctionne !!!
arnaud036 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 23/07/2007, 16h53   #4
Membre habitué
 
Avatar de arnaud036
 
Inscription : juillet 2007
Messages : 199
Détails du profil
Informations forums :
Inscription : juillet 2007
Messages : 199
Points : 120
Points : 120
C'est bon sa marche apres compilation du noyaux, pour la prise en charge d'Inotify
Voici le squelette d'un programme de base en C (Si sa peut aider):
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#include <sys/select.h>
#include <sys/inotify.h>
#include <unistd.h>
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
 
/**
 * Compilation : gcc inotify-exemple.c -o inotify-exemple -O2 -Wall -W -Werror -ansi -pedantic
 **/
 
int fd, wd;
 
void sigint_handler(int signum)
{
    (void) signum;
 
    /* Nous ne surveillons plus ce fichier/répertoire */
    if (inotify_rm_watch(fd, wd)) {
        perror("inotify_rm_watch");
        exit(EXIT_FAILURE);
    }
 
    /* Fermeture du descripteur de fichier obtenu lors de l'initialisation d'inotify */
    if (close(fd) < 0) {
        perror("close");
        exit(EXIT_FAILURE);
    }
 
    exit(EXIT_SUCCESS);
}
 
void afficher_masque(int mask)
{
    printf("Evénement : ");
    if (mask & IN_ACCESS)
        printf("Accès");
    if (mask & IN_MODIFY)
        printf("Modification");
    if (mask & IN_ATTRIB)
        printf("Attributs");
    if (mask & IN_CLOSE)
        printf("Fermeture");
    if (mask & IN_OPEN)
        printf("Ouverture");
    if (mask & IN_MOVED_FROM)
        printf("Déplacé de");
    if (mask & IN_MOVED_TO)
        printf("Déplacé vers");
    if (mask & IN_MOVE_SELF)
        printf("Lui-même déplacé");
    if (mask & IN_DELETE)
        printf("Suppression");
    if (mask & IN_CREATE)
        printf("Création");
    if (mask & IN_DELETE_SELF)
        printf("Lui-même supprimé");
    if (mask & IN_UNMOUNT)
        printf("N'est pas monté");
    if (mask & IN_Q_OVERFLOW)
        printf("Queue saturée");
    if (mask & IN_IGNORED)
        printf("Ignoré");
    if (mask & IN_ISDIR)
        printf("(répertoire)");
    else
        printf("(fichier)");
}
 
int main(int argc, char *argv[])
{
    size_t r;
    fd_set fds;
    char buffer[8192];
    struct inotify_event *event;
 
    if (argc != 2) {
        fprintf(stderr, "usage : %s fichier_ou_répertoire_à_monitorer\n", argv[0]);
        return EXIT_FAILURE;
    }
 
    /* Initialisation d'inotify */
    fd = inotify_init();
    if (fd < 0) {
        perror("inotify_init");
        return EXIT_FAILURE;
    }
 
    /* Surveillance du fichier/répertoire passé en paramètre
     * On accepte tous les évènements possibles */
    wd = inotify_add_watch(fd, argv[1], IN_ALL_EVENTS);
    if (wd < 0) {
        perror("inotify_add_watch");
        return EXIT_FAILURE;
    }
 
    printf("Monitoring : '%s' (numéro = %d)\n", argv[1], wd);
 
    /* Capture de SIGINT (Ctrl + C) */
    signal(SIGINT, sigint_handler);
 
    while (1) {
        FD_ZERO(&fds);
        FD_SET(fd, &fds);
        if (select(fd + 1, &fds, NULL, NULL, 0) <= 0) {
            continue;
        }
 
        /* Obtention des informations sur l'évènement qui vient de se produire */
        r = read(fd, buffer, sizeof(buffer));
        if (r <= 0) {
            perror("read");
            return EXIT_FAILURE;
        }
 
        event = (struct inotify_event *) buffer;
        printf("Fichier surveillé n°%d\t", event->wd);
        afficher_masque(event->mask);
 
        if (event->len) {
            printf("\tObjet : %s", event->name);
        }
        printf("\n");
    }
 
    return EXIT_FAILURE;
}
arnaud036 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 03h55.


 
 
 
 
Partenaires

Hébergement Web