Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 13
  1. #1

    Scriptino per winexe, chi mi da un aiuto?

    Ragazzi devo automatizzare un procedimento con uno script in modo da non doverlo lanciare a mano su piu di 8000 computer.

    Praticamente il comando e' il seguente

    winexe -U Administrator%password //nomepc "REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Contro l\Lsa\Kerberos\Parameters /v MaxTokenSize /t REG_DWORD /d 65535"

    Va ad inserire una chiave di registro manualmente su ogni pc.
    Ho gia fatto uno script molto idiota che mi mette su un txt tutti i nomi pc uno sotto l' altro.
    Ora mi resta solo da fare la parte che prende il dato dal file txt
    lo sostituisce al //nomepc e da il comando invio e cosi via...

    Qualcuno ha voglia di darmi una mano, bash e' una di quelle cose che ho sempre rimandato nello studio...


    Grassie ragassi
    There are two kinds of researchers:
    those that have implemented something and those that have not.
    The latter will tell you that there are 142 ways of doing things
    and that there isn't consensus on which is best.
    The former will simply tell you that 141 of them don't work.

  2. #2
    Utente di HTML.it
    Registrato dal
    Jul 2008
    Messaggi
    1,326
    Non conosco molto il linguaggio bash ma quello che chiedi non sembra difficile. Se ho capito bene la situazione, hai un file con i nomi dei pc uno sotto l'altro (quindi tante righe quanti sono i pc, supponiamo che siano n) e dovresti sostituire il nome di ciascun pc alla stringa //nomepc di quel comando e poi eseguirlo?
    every day above ground is a good one

  3. #3
    Esattamente.


    Carico la lista.

    Prendo il primo dato e lo salvo in $nomepc

    poi lancio il comando con $nomepc

    winexe -U Administrator%password //$nomepc "REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Contro l\Lsa\Kerberos\Parameters /v MaxTokenSize /t REG_DWORD /d 65535"

    Questo avanti fino alla fine del file.
    Non penso serva contare gli elementi in lista.

    Il problema e' la sintassi...
    There are two kinds of researchers:
    those that have implemented something and those that have not.
    The latter will tell you that there are 142 ways of doing things
    and that there isn't consensus on which is best.
    The former will simply tell you that 141 of them don't work.

  4. #4
    Utente di HTML.it L'avatar di moskitoita
    Registrato dal
    Feb 2004
    Messaggi
    1,255
    for i in $( cat /path/file )
    do
    echo $i
    done
    "Aiuterò le forze dell'ordine a sventrare eventuali truffatori, eventuali assassini che abbiano utilizzato l'informatica per fini malvagi"

    Salvatore Aranzulla, 15 Aprile 2007, cognome&nome, La7

  5. #5
    Utente di HTML.it
    Registrato dal
    Jul 2008
    Messaggi
    1,326
    Supponendo che tu abbia il comando generico (cioè con //nomepc) in un file comando.txt e l'elenco dei nomi dei computer in pc.txt (ovviamente i nomi li puoi sostituire con quelli che vuoi)

    codice:
    #!/bin/bash
    
    if [ -f "scriptwinexe.sh" ]
    then
    	rm "scriptwinexe.sh"
    fi
    
    touch scriptwinexe.sh
    chmod +x scriptwinexe.sh
    
    linee=$(wc -l pc.txt | cut -d " " -f 1)
    i=1
    
    while [ $linee -gt 0 ]; do
    	nome=$(head -$i pc.txt | tail -1)
    	i=$(($i + 1))
    	linee=$(($linee - 1))
    
    	sed -e s/nomepc/$nome/ comando.txt >> scriptwinexe.sh
    	echo "" >> scriptwinexe.sh;
    done
    
    exit 0
    in questo modo ti trovi tutti i comandi uno sotto l'altro in scriptwinexe.sh. In realtà non ci sarebbe bisogno di usare sed, basterebbe anche un semplice echo col comando uguale sostituendo //nomepc con $nome e redirigendo l'output su un file qualsiasi... si renderebbe inutile anche il file comando.txt

    Non so precisamente poi cosa devi fare, eventualmente modificati lo script secondo le tue necessità...
    every day above ground is a good one

  6. #6
    Ma siete i migliori adesso mi metto a sperimentarlo ed eventualemnte modificarlo alle mie esigenze.

    Sapete mica dirmi da dove avete imparato bash & co??
    Io mi devo mettere a studiarlo perche' ne ho bisogno...


    Ace mille
    There are two kinds of researchers:
    those that have implemented something and those that have not.
    The latter will tell you that there are 142 ways of doing things
    and that there isn't consensus on which is best.
    The former will simply tell you that 141 of them don't work.

  7. #7
    Moderatore di Linux e software L'avatar di francofait
    Registrato dal
    Aug 2001
    Messaggi
    13,558
    Originariamente inviato da claudiocrack
    Ma siete i migliori adesso mi metto a sperimentarlo ed eventualemnte modificarlo alle mie esigenze.

    Sapete mica dirmi da dove avete imparato bash & co??
    Io mi devo mettere a studiarlo perche' ne ho bisogno...


    Ace mille
    http://www.pluto.it/files/ildp/guide/abs/

  8. #8
    Utente di HTML.it
    Registrato dal
    Jul 2008
    Messaggi
    1,326
    Originariamente inviato da francofait
    http://www.pluto.it/files/ildp/guide/abs/
    Stavo per consigliare proprio la stessa, davvero ben fatta e approfondita
    every day above ground is a good one

  9. #9
    comando.txt

    codice:
    winexe -U Administrator%166156147 //nomepc "REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\Kerberos\Parameters /v MaxTokenSize /t REG_DWORD /d 65535"
    pc.txt

    codice:
    \\SEDPC085813
    \\NOTEBOOK076923
    \\SEDPC085787
    \\SEDPC045748
    \\SEDPC045748


    Lancio questo script.

    codice:
    #!/bin/bash
    
    if [ -f "scriptwinexe.sh" ]
    then
    	rm "scriptwinexe.sh"
    fi
    
    touch scriptwinexe.sh
    chmod +x scriptwinexe.sh
    
    linee=$(wc -l pc.txt | cut -d " " -f 1)
    i=1
    
    while [ $linee -gt 0 ]; do
    	nome=$(head -$i pc.txt | tail -1)
    	i=$(($i + 1))
    	linee=$(($linee - 1))
    
    	sed -e s/nomepc/$nome/ comando.txt >> scriptwinexe.sh
    	echo "" >> scriptwinexe.sh;
    done
    
    exit 0

    e mi ritrovo questo in scriptwinexe.sh

    codice:
    winexe -U Administrator%166156147 //\SEDPC085813 "REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\Kerberos\Parameters /v MaxTokenSize /t REG_DWORD /d 65535"
    
    winexe -U Administrator%166156147 //\NOTEBOOK076923 "REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\Kerberos\Parameters /v MaxTokenSize /t REG_DWORD /d 65535"
    
    winexe -U Administrator%166156147 //\SEDPC085787 "REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\Kerberos\Parameters /v MaxTokenSize /t REG_DWORD /d 65535"
    
    winexe -U Administrator%166156147 //\SEDPC045748 "REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\Kerberos\Parameters /v MaxTokenSize /t REG_DWORD /d 65535"
    
    winexe -U Administrator%166156147 //\SEDPC045748 "REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\Kerberos\Parameters /v MaxTokenSize /t REG_DWORD /d 65535"

    il problema che non riesco a risolvere è lo slash in rosso che non dovrebbe esserci //\ SEDPC085813
    There are two kinds of researchers:
    those that have implemented something and those that have not.
    The latter will tell you that there are 142 ways of doing things
    and that there isn't consensus on which is best.
    The former will simply tell you that 141 of them don't work.

  10. #10
    Utente di HTML.it
    Registrato dal
    Jul 2008
    Messaggi
    1,326
    Scusa ma dal file pc.txt non puoi eliminare quei due \\ davanti ai nomi dei pc? Avevo realizzato quellos script non sapendo che ci fossero...

    Per modificare pc.txt in maniera tale da passare da

    \\SEDPC085813
    \\NOTEBOOK076923
    \\SEDPC085787
    \\SEDPC045748
    \\SEDPC045748

    a

    SEDPC085813
    NOTEBOOK076923
    SEDPC085787
    SEDPC045748
    SEDPC045748

    ti basta dare da linea di comando (o a limite ce lo scrivi proprio all'inizio dello script prima del ciclo iterativo)

    codice:
    sed -i.back -e 's/[\]*//' pc.txt
    EDIT: -i apporta le modifiche effettivamente sul file in input a sed (che senza quell'opzione modificherebbe solo lo stream) e specificando l'estensione .back (o in generale qualsiasi estensione si voglia, anche inventata) si crea un file di backup pc.txt.back col contenuto originario del file, che altrimenti andrebbe irrimediabilmente perso.
    every day above ground is a good one

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.