IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Linux Discussion :

start-stop-daemon: unable to start /usr/bin/pingueur (No such file or directory)


Sujet :

Linux

  1. #1
    Membre régulier
    Profil pro
    Inscrit en
    Mai 2008
    Messages
    306
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2008
    Messages : 306
    Points : 76
    Points
    76
    Par défaut start-stop-daemon: unable to start /usr/bin/pingueur (No such file or directory)
    Bonjour,

    J'ai voulu transformer mon script python en demon et j'ai donc suivi un tuto trouvé sur CCM:

    J'ai créé un bash pour automatiser la création du démon mais au moment où je veux le démarrer, j'ai l'erreur du titre.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    #!/bin/bash
     
    sudo ln -s /opt/PingService_linux/pingueur.py /usr/bin/pingueur
    sudo ln -s /opt/PingService_linux/param.txt /usr/bin/param.txt
    sudo cp /opt/PingService_linux/pingueur /etc/init.d/pingueur
    sudo chmod 777 /etc/init.d/pingueur
    sudo update-rc.d monserveur defaults 99
    Tous les liens sont bien créés et mon skeletton est une copie du skeletton de /etc/init.d/

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    PATH=/sbin:/usr/sbin:/bin:/usr/bin
    DESC="teste serveur"
    NAME=pingueur
    DAEMON=/usr/bin/$NAME
    DAEMON_ARGS=""
    PIDFILE=/var/run/$NAME.pid
    SCRIPTNAME=/etc/init.d/$NAME
    Il a bien tous les droits et le lien dans /usr/bin/pingueur pointe bien vers /opt/prog/pingueur.py

    Merci de votre aide

  2. #2
    Invité
    Invité(e)
    Par défaut
    Salut,

    Pourtant le message d'erreur indique clairement qu'il ne trouve pas /usr/bin/pingueur

    Peux-tu fournir le résultat de la commande suivante?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    ls -l /usr/bin/pingueur

  3. #3
    Membre régulier
    Profil pro
    Inscrit en
    Mai 2008
    Messages
    306
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2008
    Messages : 306
    Points : 76
    Points
    76
    Par défaut
    Voilà la réponse de la commande

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    lrwxrwxrwx 1 root root 34 2011-08-29 14:53 /usr/bin/pingueur -> /opt/PingService_linux/pingueur.py
    et tant que j'y suis le ls -l de /opt/PingService_linux/pingueur.py

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    -rwxrwxrwx 1 fma fma 12000 2011-08-29 13:35 /opt/PingService_linux/pingueur.py
    et ls -l /etc/init.d/pingueur

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    -rwxrwxrwx 1 root root 4231 2011-08-29 15:46 /etc/init.d/pingueur
    Voilà et merci

  4. #4
    Rédacteur

    Avatar de ram-0000
    Homme Profil pro
    Consultant en sécurité
    Inscrit en
    Mai 2007
    Messages
    11 517
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 61
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Consultant en sécurité
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Mai 2007
    Messages : 11 517
    Points : 50 367
    Points
    50 367
    Par défaut
    Visiblement, /usr/bin/pingueur est un lien sur /opt/PingService_linux/pingueur.py qui semble (d'après l'extension) être un script python.

    Es-tu sûr d'avoir dans le path de ton script de démarrage le chemin pour atteindre l'interpréteur python ?

  5. #5
    Membre régulier
    Profil pro
    Inscrit en
    Mai 2008
    Messages
    306
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2008
    Messages : 306
    Points : 76
    Points
    76
    Par défaut
    Dans le fichier pingueur se trouvant dans /etc/init.d/ ? Vous vovoulez dire? Non

    Sous quelle forme doit il se trouver?

    Merci de votre aide

  6. #6
    Rédacteur

    Avatar de ram-0000
    Homme Profil pro
    Consultant en sécurité
    Inscrit en
    Mai 2007
    Messages
    11 517
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 61
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Consultant en sécurité
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Mai 2007
    Messages : 11 517
    Points : 50 367
    Points
    50 367
    Par défaut
    Citation Envoyé par ram-0000 Voir le message
    dans le path de ton script de démarrage

  7. #7
    Membre régulier
    Profil pro
    Inscrit en
    Mai 2008
    Messages
    306
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2008
    Messages : 306
    Points : 76
    Points
    76
    Par défaut
    Oui dans mon fichier pingeur.py j ai bien la ligne Deso mais je debute

    Merci de votre aide

  8. #8
    Rédacteur

    Avatar de ram-0000
    Homme Profil pro
    Consultant en sécurité
    Inscrit en
    Mai 2007
    Messages
    11 517
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 61
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Consultant en sécurité
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Mai 2007
    Messages : 11 517
    Points : 50 367
    Points
    50 367
    Par défaut
    non, pas dans pingeur.py mais dans /etc/init.d/pingueur

    Autre chose, la bonne "syntaxe/manière de faire" dans le fichier pingueur.py, c'est
    pas

  9. #9
    Membre régulier
    Profil pro
    Inscrit en
    Mai 2008
    Messages
    306
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2008
    Messages : 306
    Points : 76
    Points
    76
    Par défaut
    J'ai rajouté : #!/usr/bin/python
    et j'ai modifié la ligne PATH en rajoutant à la fin le chemin python
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/bin/python
    au début de mon fichier mais toujours la même erreur

    Merci

  10. #10
    Invité
    Invité(e)
    Par défaut
    Re,

    La variable PATH doit recevoir une série de répertoires pas des fichiers. Donc la ligne que tu as ajoutée ne sert à rien.

    Pourrais-tu fournir le contenu complet du script /etc/init.d/pingeur ainsi que ton script python?

  11. #11
    Membre régulier
    Profil pro
    Inscrit en
    Mai 2008
    Messages
    306
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2008
    Messages : 306
    Points : 76
    Points
    76
    Par défaut
    Voilà mon lanceur

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    #! /bin/sh
    ### BEGIN INIT INFO
    # Provides:          skeleton
    # Required-Start:    $remote_fs $syslog
    # Required-Stop:     $remote_fs $syslog
    # Default-Start:     2 3 4 5
    # Default-Stop:      0 1 6
    # Short-Description: Example initscript
    # Description:       This file should be used to construct scripts to be
    #                    placed in /etc/init.d.
    ### END INIT INFO
     
    # Author: Foo Bar <foobar@baz.org>
    #
    # Please remove the "Author" lines above and replace them
    # with your own name if you copy and modify this script.
     
    # Do NOT "set -e"
     
    # PATH should only include /usr/* if it runs after the mountnfs.sh script
    PATH=/sbin:/usr/sbin:/bin:/usr/bin
    DESC="teste serveur"
    NAME=pingueur
    DAEMON=/usr/bin/$NAME
    DAEMON_ARGS=""
    PIDFILE=/var/run/$NAME.pid
    SCRIPTNAME=/etc/init.d/$NAME
     
    # Exit if the package is not installed
    [ -x "$DAEMON" ] || exit 0
     
    # Read configuration variable file if it is present
    [ -r /etc/default/$NAME ] && . /etc/default/$NAME
     
    # Load the VERBOSE setting and other rcS variables
    . /lib/init/vars.sh
     
    # Define LSB log_* functions.
    # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
    . /lib/lsb/init-functions
     
    #
    # Function that starts the daemon/service
    #
    do_start()
    {
    	# Return
    	#   0 if daemon has been started
    	#   1 if daemon was already running
    	#   2 if daemon could not be started
    	start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
    		|| return 1
    	start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
    		$DAEMON_ARGS \
    		|| return 2
    	# Add code here, if necessary, that waits for the process to be ready
    	# to handle requests from services started subsequently which depend
    	# on this one.  As a last resort, sleep for some time.
    }
     
    #
    # Function that stops the daemon/service
    #
    do_stop()
    {
    	# Return
    	#   0 if daemon has been stopped
    	#   1 if daemon was already stopped
    	#   2 if daemon could not be stopped
    	#   other if a failure occurred
    	start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
    	RETVAL="$?"
    	[ "$RETVAL" = 2 ] && return 2
    	# Wait for children to finish too if this is a daemon that forks
    	# and if the daemon is only ever run from this initscript.
    	# If the above conditions are not satisfied then add some other code
    	# that waits for the process to drop all resources that could be
    	# needed by services started subsequently.  A last resort is to
    	# sleep for some time.
    	start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
    	[ "$?" = 2 ] && return 2
    	# Many daemons don't delete their pidfiles when they exit.
    	rm -f $PIDFILE
    	return "$RETVAL"
    }
     
    #
    # Function that sends a SIGHUP to the daemon/service
    #
    do_reload() {
    	#
    	# If the daemon can reload its configuration without
    	# restarting (for example, when it is sent a SIGHUP),
    	# then implement that here.
    	#
    	start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
    	return 0
    }
     
    case "$1" in
      start)
    	[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
    	do_start
    	case "$?" in
    		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
    		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
    	esac
    	;;
      stop)
    	[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
    	do_stop
    	case "$?" in
    		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
    		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
    	esac
    	;;
      status)
           status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
           ;;
      #reload|force-reload)
    	#
    	# If do_reload() is not implemented then leave this commented out
    	# and leave 'force-reload' as an alias for 'restart'.
    	#
    	#log_daemon_msg "Reloading $DESC" "$NAME"
    	#do_reload
    	#log_end_msg $?
    	#;;
      restart|force-reload)
    	#
    	# If the "reload" option is implemented then remove the
    	# 'force-reload' alias
    	#
    	log_daemon_msg "Restarting $DESC" "$NAME"
    	do_stop
    	case "$?" in
    	  0|1)
    		do_start
    		case "$?" in
    			0) log_end_msg 0 ;;
    			1) log_end_msg 1 ;; # Old process is still running
    			*) log_end_msg 1 ;; # Failed to start
    		esac
    		;;
    	  *)
    	  	# Failed to stop
    		log_end_msg 1
    		;;
    	esac
    	;;
      *)
    	#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
    	echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
    	exit 3
    	;;
    esac
     
    :
    et voilà mon script qui sert à pinguer une adresse et tester s'il répond

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    #!/usr/bin/python
    # -*-coding:Utf-8 -* 
    import os,sys
    import ftplib as ftp
    import sched
    import time
    import datetime
    import threading
    import subprocess
    import Tkinter
    import re
    import paramiko
     
    #répertoire courant du fichier
    dir_path = os.path.abspath(os.path.dirname(sys.argv[0]))
    racine=Tkinter.Tk()
    racine.title("Pointage")
     
     
    #sys.path[0]
    #recupere les parametres du fichier
    ip = ""
    pathLoc = ""
    pathServ = ""
    user = ""
    passwd = ""
    time = ""
    port = ""
    if os.path.isfile(dir_path+'/param.txt') == True or os.path.isfile(dir_path+'/param.txt') == 'True':
        logfile = open(dir_path+'/param.txt', 'r')
        dic = {}
        line = logfile.readline()
        cpt = 0
        while line:
            detail = line.split("=")
            if detail[0] == "ip":
                ip = detail[1].strip("\r").strip("\n")
            elif detail[0] == "timeout":
                time = detail[1].strip("\r").strip("\n")
            elif detail[0] == "pathLoc":
                pathLoc = detail[1].strip("\r").strip("\n")
            elif detail[0] == "pathServ":
                pathServ = detail[1].strip("\r").strip("\n")
            elif detail[0] == "user":
                user = detail[1].strip("\r").strip("\n")
            elif detail[0] == "passwd":
                passwd = detail[1].strip("\r").strip("\n")
            elif detail[0] == "port":
                port = detail[1].strip("\r").strip("\n")
            elif detail[0] == "terminal":
                terminal = detail[1].strip("\r").strip("\n")
            elif detail[0] == "typeTimbre":
                typeTimbre = detail[1].strip("\r").strip("\n")
     
            line = logfile.readline()
    else:
        texte=Tkinter.Label(racine, text="Veuillez joindre un fichier 'param.txt' dans "+dir_path, fg="black")
        boutonESC=Tkinter.Button(racine, text="Fermer", command=racine.withdraw)
        texte.pack(side=Tkinter.TOP)
        boutonESC.pack(side=Tkinter.BOTTOM)
        boutonESC.configure(state='normal',background='red')
        racine.configure(width=260,height=150)
        racine.mainloop()
     
    if ip == "":
        texte=Tkinter.Label(racine, text="Veuillez ajouter une ligne 'ip=xxx.xxx.xxx.xxx' fichier dans "+dir_path+"param.txt", fg="black")
        boutonESC=Tkinter.Button(racine, text="Fermer", command=racine.withdraw)
        texte.pack(side=Tkinter.TOP)
        boutonESC.pack(side=Tkinter.BOTTOM)
        boutonESC.configure(state='normal',background='red')
        racine.configure(width=260,height=150)
        racine.mainloop()
     
    if pathLoc == "":
        texte=Tkinter.Label(racine, text="Veuillez ajouter une ligne 'pathLoc=chemin des pointages locales' fichier dans "+dir_path+"param.txt", fg="black")
        boutonESC=Tkinter.Button(racine, text="Fermer", command=racine.withdraw)
        texte.pack(side=Tkinter.TOP)
        boutonESC.pack(side=Tkinter.BOTTOM)
        boutonESC.configure(state='normal',background='red')
        racine.configure(width=260,height=150)
        racine.mainloop()
     
    if pathServ == "":
        texte=Tkinter.Label(racine, text="Veuillez ajouter une ligne 'pathServ=chemin des pointages à uploader' fichier dans "+dir_path+"param.txt", fg="black")
        boutonESC=Tkinter.Button(racine, text="Fermer", command=racine.withdraw)
        texte.pack(side=Tkinter.TOP)
        boutonESC.pack(side=Tkinter.BOTTOM)
        boutonESC.configure(state='normal',background='red')
        racine.configure(width=260,height=150)
        racine.mainloop()
     
    if user == "":
        texte=Tkinter.Label(racine, text="Veuillez ajouter une ligne 'user=user pour se connecter au serveur"+dir_path+"param.txt", fg="black")
        boutonESC=Tkinter.Button(racine, text="Fermer", command=racine.withdraw)
        texte.pack(side=Tkinter.TOP)
        boutonESC.pack(side=Tkinter.BOTTOM)
        boutonESC.configure(state='normal',background='red')
        racine.configure(width=260,height=150)
        racine.mainloop()
     
    if passwd == "":
        texte=Tkinter.Label(racine, text="Veuillez ajouter une ligne 'passwd=password pour se connecter au serveur"+dir_path+"param.txt", fg="black")
        boutonESC=Tkinter.Button(racine, text="Fermer", command=racine.withdraw)
        texte.pack(side=Tkinter.TOP)
        boutonESC.pack(side=Tkinter.BOTTOM)
        boutonESC.configure(state='normal',background='red')
        racine.configure(width=260,height=150)
        racine.mainloop()
     
    if time == "":
        texte=Tkinter.Label(racine, text="Veuillez ajouter une ligne 'timeout=temps en seconde pour tester le serveur"+dir_path+"param.txt", fg="black")
        boutonESC=Tkinter.Button(racine, text="Fermer", command=racine.withdraw)
        texte.pack(side=Tkinter.TOP)
        boutonESC.pack(side=Tkinter.BOTTOM)
        boutonESC.configure(state='normal',background='red')
        racine.configure(width=260,height=150)
        racine.mainloop()
     
    if port == "":
        port = 22
     
    if terminal == "":
        texte=Tkinter.Label(racine, text="Veuillez ajouter une ligne 'terminal=nom du terminal (ex:@J)' fichier dans "+dir_path+"param.txt", fg="black")
        boutonESC=Tkinter.Button(racine, text="Fermer", command=racine.withdraw)
        texte.pack(side=Tkinter.TOP)
        boutonESC.pack(side=Tkinter.BOTTOM)
        boutonESC.configure(state='normal',background='red')
        racine.configure(width=260,height=150)
        racine.mainloop()
     
    if typeTimbre == "":
        texte=Tkinter.Label(racine, text="Veuillez ajouter une ligne 'typeTimbre=' fichier dans "+dir_path+"param.txt", fg="black")
        boutonESC=Tkinter.Button(racine, text="Fermer", command=racine.withdraw)
        texte.pack(side=Tkinter.TOP)
        boutonESC.pack(side=Tkinter.BOTTOM)
        boutonESC.configure(state='normal',background='red')
        racine.configure(width=260,height=150)
        racine.mainloop()
     
     
    logfile.close()
     
    txtHr=Tkinter.Label(racine, text="", fg="black")
    texte=Tkinter.Label(racine, text="Entrez votre n° d'identification", fg="black")
    txtInfoServ=Tkinter.Label(racine, text="Serveur actif", fg="black")
    txtIP=Tkinter.Label(racine, text=ip, fg="black")
    bouton=Tkinter.Button(racine, text="Pointer", command=lambda: save(valsaisir.get(),racine,saisie,terminal,typeTimbre))
    boutonESC=Tkinter.Button(racine, text="Fermer", command=racine.quit)
    valsaisir=Tkinter.StringVar() #variable to get value
    saisie=Tkinter.Entry(textvariable=valsaisir, width=30)
     
    isDown = False
    isOpen = False
    cpt = 0
    def MyTimer(cpt,tempo = float(time)):
        global isOpen
        #si linux   
        if sys.platform == "linux2":
            lPing = subprocess.Popen(["ping","-c", "1 ", ip ],  
    					    stdout = subprocess.PIPE, 
    					    stderr = subprocess.PIPE) 
        elif sys.platform == "win32":
            lPing = subprocess.Popen(["ping","-n", "1 ", ip ],  
    					    stdout = subprocess.PIPE, 
    					    stderr = subprocess.PIPE,shell=True) 
     
        sLigne, erreur = lPing.communicate()
        #print sLigne
        transmis = 0
        received = 0
        loss = 100
        time = 0
        cpt = int(cpt) + 1
        #si linux   
        if sys.platform == "linux2":
            info_reg = info_reg = re.search(r'(\d+) packets transmitted',sLigne,re.M)
            if info_reg:
                transmis = int(info_reg.group(1))
            info_reg = info_reg = re.search(r'(\d+) received',sLigne,re.M)
            if info_reg:
                received = int(info_reg.group(1))
            info_reg = info_reg = re.search(r'(\d+)% packet loss',sLigne,re.M)
            if info_reg:
                loss = int(info_reg.group(1))
                if loss == 100:
                    loss = 1
            info_reg = info_reg = re.search(r'time (\d+)ms',sLigne,re.M)
            if info_reg:
                time = int(info_reg.group(1))
     
        elif sys.platform == "win32":
            info_reg = info_reg = re.search(r'envoy\Ds = (\d+)',sLigne,re.M)
            if info_reg:
                transmis = int(info_reg.group(1))
            else:
                info_reg = info_reg = re.search(r'Sent = (\d+)',sLigne,re.M)
                if info_reg:
                    transmis = int(info_reg.group(1))
     
            info_reg = info_reg = re.search(r're\Dus = (\d+)',sLigne,re.M)
            if info_reg:
                received = int(info_reg.group(1))
            else:
                info_reg = info_reg = re.search(r'Received = (\d+)',sLigne,re.M)
                if info_reg:
                    received = int(info_reg.group(1))
     
            info_reg = info_reg = re.search(r'perte (\d+)%',sLigne,re.M)
            if info_reg:
                loss = int(info_reg.group(1))
            else:
                info_reg = info_reg = re.search(r'Lost = (\d+)',sLigne,re.M)
                if info_reg:
                    loss = int(info_reg.group(1))
     
            info_reg = info_reg = re.search(r'Moyenne = (\d+)ms',sLigne,re.M)
            if info_reg:
     
                time = int(info_reg.group(1))
     
     
        now = datetime.datetime.now()
        #print isOpen
        #si l'expression régulière a donné un résultat
        if transmis > 0:
            isDown = False
            if received == 0:
                isDown = True
     
     
            if isDown == False or isDown == 'False':
                #Ferme la fenêtre pour encoder les pointages locales
                if isOpen == True or isOpen == 'True':
                    racine.after_idle(showroot,1)
     
                isOpen = False
                #si le serveur répond après avoir été down et qu'il y a un fichier à uploader alors upload
    	    #recupere les parametres du fichier 
                if(os.path.exists(pathLoc) and os.path.getsize(pathLoc) > 0):
                    try:
                                            #pathServ = "/var/www/aigs2/DOC/ANC/tagada.txt"
                        #print "je suis le porc"+user2+"&"+passwd2
                        transport = paramiko.Transport((ip, int(port)))
                        transport.connect(username = user, password = passwd) 
                        sftp = paramiko.SFTPClient.from_transport(transport) 
                        sftp.put(pathLoc,pathServ) 
                        sftp.close() 
                        transport.close()
                        os.remove(pathLoc)                  #supprime fichier
                    except ValueError:
                        print "erreur"
            else:
                if(received == 0 and (isOpen == False or isOpen == 'False')):
                    #print now.strftime("%d/%m/%YT%H:%M:%S")
                    racine.after_idle(showroot,0)
                    isOpen = True
     
        else:
            if(received == 0 and (isOpen == False or isOpen == 'False')):
                #print now.strftime("%d/%m/%YT%H:%M:%S")
                racine.after_idle(showroot,0)
                isOpen = True
     
     
        threading.Timer(tempo, MyTimer, [cpt,tempo]).start()
     
    def save(val,racine,saisie,terminal,typeTimbre):
            #print os.path.exists(pathLoc.strip("\n"))
    	if(os.path.exists(pathLoc.strip("\n")) == False or os.path.exists(pathLoc.strip("\n")) == 'False'):
    		file(pathLoc, 'w')
     
    	#print pathLoc
    	now = datetime.datetime.now()
    	line = terminal+"0"+typeTimbre+now.strftime("%y%m%d%H%M%S")+"000000000000"+val+'\n'
    	logfile2 = open(pathLoc, 'a+') 
    	logfile2.write(line)
    	logfile2.close()
    	isDown = True;
    	#vide textbox
    	saisie.delete(0,Tkinter.END)
     
    def showroot(param):
        now = datetime.datetime.now() 
        if param == 0:
            txtInfoServ.config(text="Serveur inactif")
            bouton.configure(state='normal', text="Pointer",background='red',command=lambda: save(valsaisir.get(),racine,saisie,terminal,typeTimbre))
            saisie.configure(state='normal')
            txtHr.config(text=now.strftime("%H:%M:%S"))
            #boutonESC.pack_forget()
        else:
            txtInfoServ.config(text="Serveur actif")
            bouton.configure(state='normal', text="Ok",background='green',command=racine.withdraw)
            saisie.configure(state='disabled')
            txtHr.config(text=now.strftime("%H:%M:%S"))
     
        racine.deiconify()
     
    def hideme():
    	racine.withdraw()
    	MyTimer(cpt,float(time))
     
     
    def IntercepteClose():
        global isOpen
        isOpen = False
        racine.withdraw()
     
     
    txtHr.pack(side=Tkinter.TOP)
    texte.pack(side=Tkinter.TOP)
    saisie.pack()
    txtIP.pack(side=Tkinter.BOTTOM)
    txtInfoServ.pack(side=Tkinter.BOTTOM)
    bouton.pack(side=Tkinter.BOTTOM)
    hideme()
    racine.configure(width=260,height=150)
    racine.protocol("WM_DELETE_WINDOW", IntercepteClose)
    racine.mainloop()

  12. #12
    Invité
    Invité(e)
    Par défaut
    Alors j'ai fait un test avec tes scripts de mon côté et ça semble fonctionner

    Script shell dans init.d
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    root@vm-ubuntu8:~# ls -l /etc/init.d/pingueur
    -rwxr-xr-x 1 root root 4240 2011-08-30 22:34 /etc/init.d/pingueur
    root@vm-ubuntu8:~# file /etc/init.d/pingueur
    /etc/init.d/pingueur: Bourne-Again shell script text executable
    Script python dans /usr/bin
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    root@vm-ubuntu8:~# ls -l /usr/bin/pingueur
    -rwxr-xr-x 1 root root 11798 2011-08-30 21:13 /usr/bin/pingueur
    root@vm-ubuntu8:~# file /usr/bin/pingueur
    /usr/bin/pingueur: python script text executable
    Execution du script shell dans init.d en mode debug

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    root@vm-ubuntu8:~# sh -xv /etc/init.d/pingueur start
    Fin de l'ouput

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    esac
    + case "$1" in
    + '[' no '!=' no ']'
    + do_start
    + start-stop-daemon --start --quiet --pidfile /var/run/pingueur.pid --exec /usr/bin/pingueur --test
    + start-stop-daemon --start --quiet --pidfile /var/run/pingueur.pid --exec /usr/bin/pingueur --
    Traceback (most recent call last):
      File "/usr/bin/pingueur", line 12, in <module>
        import paramiko
    ImportError: No module named paramiko
    + return 2
    + case "$?" in
    + '[' no '!=' no ']'
    
    :
    Donc de mon côté le script python est bien executé mais il me renvoie une erreur à cause d'un module manquant.


    Peux-tu executer de ton côté la commande suivante dans le shell?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    start-stop-daemon -v --start --pidfile /var/run/pingueur.pid --exec /usr/bin/pingueur --

  13. #13
    Membre régulier
    Profil pro
    Inscrit en
    Mai 2008
    Messages
    306
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2008
    Messages : 306
    Points : 76
    Points
    76
    Par défaut
    J'ai testé la commande et voilà le resultat

    Starting /usr/bin/pingueur...
    start-stop-daemon: unable to start /usr/bin/pingueur (No such file or directory)

  14. #14
    Invité
    Invité(e)
    Par défaut
    Et de cette manière quel est le résultat?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    start-stop-daemon -v --start --pidfile /var/run/pingueur.pid --exec /usr/bin/python -- /usr/bin/pingueur

  15. #15
    Membre régulier
    Profil pro
    Inscrit en
    Mai 2008
    Messages
    306
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2008
    Messages : 306
    Points : 76
    Points
    76
    Par défaut
    Toujours le même résultat

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    Starting /usr/bin/pingueur...
    start-stop-daemon: unable to start /usr/bin/pingueur (No such file or directory)

  16. #16
    Invité
    Invité(e)
    Par défaut
    Salut,

    As-tu bien copié collé la commande que je t'ai indiquée car logiquement tu devrais voir "starting /usr/bin/python" et non "starting /usr/bin/pingueur"

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    root@vm-ubuntu8:~# start-stop-daemon -v --start --pidfile /var/run/pingueur.pid --exec /usr/bin/python -- /usr/bin/pingueur
    Starting /usr/bin/python...
    Traceback (most recent call last):
      File "/usr/bin/pingueur", line 12, in <module>
        import paramiko
    ImportError: No module named paramiko

  17. #17
    Membre régulier
    Profil pro
    Inscrit en
    Mai 2008
    Messages
    306
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2008
    Messages : 306
    Points : 76
    Points
    76
    Par défaut
    Génial cette ligne fonctionne mais maintenant comment faire pour que le demon démarre avec la machine?

    De plus est-ce-qu'il est possible comme sous windows avec py2exe de créer un démon sans devoir installer python?

    Merci beaucoup pour votre aide

  18. #18
    Invité
    Invité(e)
    Par défaut
    Salut,

    Concernant le démarrage automatique, il me semble que tu avais déjà créé un autre post à ce sujet. (utilisation de update-rc.d).

    Pour l'équivalent de py2exe, tu as ceci d'après mes recherches.
    http://www.pyinstaller.org/

    Mais Je n'ai jamais essayé. Donc à toi de voir.

  19. #19
    Rédacteur
    Avatar de lavazavio
    Homme Profil pro
    Inscrit en
    Décembre 2004
    Messages
    1 673
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Rhône (Rhône Alpes)

    Informations forums :
    Inscription : Décembre 2004
    Messages : 1 673
    Points : 2 412
    Points
    2 412
    Par défaut
    Le shebang de ton script shell n'est pas non plus mais tu l'as peut-être déjà corrigé...

    et pas

Discussions similaires

  1. Réponses: 3
    Dernier message: 03/02/2011, 18h11
  2. Daemon Linux: start-stop-daemon
    Par ketzaldev dans le forum Linux
    Réponses: 1
    Dernier message: 10/09/2009, 20h16
  3. bin/sh: bad interpreter: No such file or directory
    Par PoZZyX dans le forum Administration système
    Réponses: 3
    Dernier message: 02/06/2009, 21h53
  4. start-stop-daemon pas de pid
    Par Fluxy dans le forum Debian
    Réponses: 2
    Dernier message: 05/10/2008, 19h02
  5. /usr/bin/Kaffe: No such file or directory
    Par kris1 dans le forum Général Java
    Réponses: 7
    Dernier message: 03/03/2008, 14h55

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo