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

Scripts/Batch Discussion :

SCRIPT SHUTDOWN A GRANDE ECHELLE


Sujet :

Scripts/Batch

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Homme Profil pro
    Lycéen
    Inscrit en
    Décembre 2014
    Messages
    21
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 27
    Localisation : France, Ille et Vilaine (Bretagne)

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

    Informations forums :
    Inscription : Décembre 2014
    Messages : 21
    Par défaut SCRIPT SHUTDOWN A GRANDE ECHELLE
    Bonjour tout le monde ,

    Je souhaiterais avoir votre avis sur ce code que j'avais produit sous linux , je l'ai adapté plus ou moins mais j'ai quelque doute pourriez vous m'aidez S'il vous plaît ?

    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
    #!/bin/bash
    
    RESULT="1"
    COUNTER=2
    
    
    while [  $COUNTER -lt 226 ]; do
    
    PING=$(ping 9.27.185."$COUNTER" -c 1 | grep -E -o '[0-9]+ received' | cut -f1 -d' ')
    if [ "$RESULT" == "$PING" ]
    
    
    	echo $(date +"%A %d %m %Y ") $(date +%R)"SUCCESSFULL TO PING 9.27.185.."$COUNTER
    	echo $(date +"%A %d %m %Y ") $(date +%R )"SHUTDOWN IN PROGRESS ON 9.27.185."$COUNTER	
    
    	echo "connexion in progress"
    	shutdown -h now 9.27.185.$COUNTER
    	echo "shutdown ..."
    
    then
    else
    	echo $(date +"%A %d %m %Y " )$(date +%R)"FAILED TO PING 9.27.185."$COUNTER
    fi
    
    let COUNTER=COUNTER+1 
    done

  2. #2
    Membre émérite Avatar de devilsnake88
    Homme Profil pro
    Technicien maintenance
    Inscrit en
    Janvier 2013
    Messages
    453
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Technicien maintenance
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Janvier 2013
    Messages : 453
    Par défaut
    Bonjour, un début de script:
    Code bat : 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
    @echo off & cls
    setLocal EnableDelayedExpansion
     
    set current_path=%~dp0
    set current_path_modified=%current_path:~0,-1%
    set list=ComputersToShutdown
    set numberofcomputers=226
    set baseIP=9.27.185.
     
    if not exist "%current_path_modified%\ComputersToShutdown\" md "%current_path_modified%\ComputersToShutdown\"
    if exist "%current_path_modified%\ComputersToShutdown\%list%.txt" del /F /S /Q "%current_path_modified%\ComputersToShutdown\%list%.txt"
     
    FOR /L %%i IN (1,1,%numberofcomputers%) DO (
      ECHO %baseIP%%%i>>"%current_path_modified%\ComputersToShutdown\%list%.txt"
    )
     
    for /f "tokens=*" %%a in (%current_path_modified%\ComputersToShutdown\%list%.txt) do (
    	title Ping en cours sur %%a
    	set nom=%%a
    	set /a N+=1
    	set v!N!=%%a
    	ping !nom! -n 1 -w 100 -4 -l 8 > nul
    	if not errorlevel 1 (
    		set /A compteur+=1
    		set v!compteur!=%%a
    		echo !nom! est allume, on le shutdown
            call :Shutdown !nom!
    	)
    	if errorlevel 1 (
    		echo !nom! est eteind
    	)
    )
     
    :Shutdown
    if not "%1"=="" (
    	title Shutdown en cours sur %1
    	echo Shutdown en cours sur %1
    	echo shutdown /h \\%1 /t 0 /s /f
    	echo Shutdown effectue sur : %1
        goto :Exit
    ) else (
        echo ERREUR!
        goto :Exit
    )
     
    :Exit
    pause
    exit

Discussions similaires

  1. [Batch] Script shutdown avec temps
    Par Castiel777 dans le forum Scripts/Batch
    Réponses: 9
    Dernier message: 29/09/2013, 19h15
  2. Shutdown Script Process
    Par Golruck dans le forum Bases de données
    Réponses: 3
    Dernier message: 04/05/2007, 15h45
  3. Comment faire des tests à grande echelle?
    Par kisitomomotene dans le forum Test
    Réponses: 2
    Dernier message: 16/12/2006, 20h48
  4. Recherche script de grand classique
    Par zooffy dans le forum ASP.NET
    Réponses: 1
    Dernier message: 01/12/2006, 20h22
  5. [PHP-JS] Script qui me pose de grands problemes
    Par MadSoldier dans le forum Langage
    Réponses: 3
    Dernier message: 22/06/2006, 21h33

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