Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Come creare script per eseguire comandi su macchine remote
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) Forum di discussione italiano
View previous topic :: View next topic  
Author Message
digu
Apprentice
Apprentice


Joined: 26 Feb 2006
Posts: 201
Location: Verona

PostPosted: Fri Aug 25, 2006 1:47 pm    Post subject: Come creare script per eseguire comandi su macchine remote Reply with quote

Ciao a tutti...
Volevo sapere se qualcuno sa indicarmi come e' possibile creare degli script che eseguano comandi su macchine remote...
faccio un esempio...

Ho a disposizione 3 macchine: A, B, C;
Sulla macchina A invoco uno script che (ad esempio) fa partire un
Code:
emerge --sync

anche su B e C...

E' possibile fare una cosa del genere? esistono programmi che lo fanno gia'?
Grazie in anticipo...
_________________
..:[DiGu]:.
Back to top
View user's profile Send private message
Kernel78
Moderator
Moderator


Joined: 24 Jun 2005
Posts: 3654

PostPosted: Fri Aug 25, 2006 1:55 pm    Post subject: Reply with quote

Code:
ssh host comando

Ma rimane in attesa che il comando termini ...
Se quello che vuoi è semplicemente syncare delle macchine ti conviene mettere il comando in cron.

Dovresti spiegare meglio quale risultato vuoi ottenere
_________________
Le tre grandi virtù di un programmatore: pigrizia, impazienza e arroganza. (Larry Wall).
Prima di postare un file togli i commenti con
Code:
grep -vE '(^[[:space:]]*($|(#|!|;|//)))'
Back to top
View user's profile Send private message
comio
Advocate
Advocate


Joined: 03 Jul 2003
Posts: 2191
Location: Taranto

PostPosted: Fri Aug 25, 2006 2:20 pm    Post subject: Re: Come creare script per eseguire comandi su macchine remo Reply with quote

digu wrote:
Ciao a tutti...
Volevo sapere se qualcuno sa indicarmi come e' possibile creare degli script che eseguano comandi su macchine remote...
faccio un esempio...

Ho a disposizione 3 macchine: A, B, C;
Sulla macchina A invoco uno script che (ad esempio) fa partire un
Code:
emerge --sync

anche su B e C...

E' possibile fare una cosa del genere? esistono programmi che lo fanno gia'?
Grazie in anticipo...


ti rispondo alla domanda: Puoi usare ssh con le opzioni -f ed -n per far eseguire in background... oppure redirigere l'output di ssh (>>) e mettere & a fine riga.

Poi, per il tuo problema: sei sicuro che l'esecuzione di comandi remoti sia la soluzione? non è forse meglio configurare il cron delle macchine oppure usare porzioni di filesystem condivisi (per il portage per esempio?).

ciao
_________________
RTFM!!!!

e

http://www.comio.it
:)
Back to top
View user's profile Send private message
X-Act!
Apprentice
Apprentice


Joined: 22 Nov 2004
Posts: 245
Location: /home/xact/

PostPosted: Fri Aug 25, 2006 2:33 pm    Post subject: Reply with quote

Un po' di tempo fa sul forum c'era uno script che faceva esattamente quello che cerchi: gli davi un comando ed una lista di host e lui, tramite ssh, eseguiva quel comando su tutti gli host elencati.
Lo trovai molto carino, anche se per me del tutto inutile ed inutilizzabile avendo ancora una sola macchina...

Purtroppo non ho idea del nome, ma con un po' di paziente "Ricerca Rapida" sono sicuro che lo trovi!
_________________
"Io non mi sento obbligato a credere che lo stesso Dio che ci ha dotato di senso, ragione ed intelletto intendesse che noi ne facessimo a meno."
-- Galileo Galilei
Back to top
View user's profile Send private message
federico
Advocate
Advocate


Joined: 18 Feb 2003
Posts: 3272
Location: Italy, Milano

PostPosted: Fri Aug 25, 2006 2:40 pm    Post subject: Reply with quote

In particolare puoi utilizzare l'opzione "command" di ssh, che come si legge nel man

Quote:

ssh [-1246AaCfgkMNnqsTtVvXxY] [-b bind_address] [-c cipher_spec] [-D [bind_address:]port]
[-e escape_char] [-F configfile] [-i identity_file] [-L [bind_address:]port:host:hostport]
[-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port] [-R
[bind_address:]port:host:hostport] [-S ctl_path] [-w tunnel:tunnel] [user@]hostname
[command]

If command is specified, it is executed on the remote host instead of a login shell.



Per ovviare al problema di automazione dovuto all'immissione delle password ti consiglio di utilizzare chiavi di ssh statiche.

Quote:

The methods available for authentication are: host-based authentication, public key authentica-
tion, challenge-response authentication, and password authentication. Authentication methods
are tried in the order specified above, though protocol 2 has a configuration option to change
the default order: PreferredAuthentications.

_________________
Sideralis www.sideralis.org
Pic http://blackman.amicofigo.com/gallery
Arduino http://www.arduino.cc
Chi aveva potuto aveva spaccato
2000 pezzi buttati là
Molti saluti,qualche domanda
Semplice come musica punk
Back to top
View user's profile Send private message
digu
Apprentice
Apprentice


Joined: 26 Feb 2006
Posts: 201
Location: Verona

PostPosted: Sat Aug 26, 2006 8:06 am    Post subject: Re: Come creare script per eseguire comandi su macchine remo Reply with quote

comio wrote:
digu wrote:
Ciao a tutti...
Volevo sapere se qualcuno sa indicarmi come e' possibile creare degli script che eseguano comandi su macchine remote...
faccio un esempio...

Ho a disposizione 3 macchine: A, B, C;
Sulla macchina A invoco uno script che (ad esempio) fa partire un
Code:
emerge --sync

anche su B e C...

E' possibile fare una cosa del genere? esistono programmi che lo fanno gia'?
Grazie in anticipo...


ti rispondo alla domanda: Puoi usare ssh con le opzioni -f ed -n per far eseguire in background... oppure redirigere l'output di ssh (>>) e mettere & a fine riga.

Poi, per il tuo problema: sei sicuro che l'esecuzione di comandi remoti sia la soluzione? non è forse meglio configurare il cron delle macchine oppure usare porzioni di filesystem condivisi (per il portage per esempio?).

ciao


La mia necessita' e' quella di mantenere piu' macchine e se installo su di una un sw, lo devo installare anche sulle altre... volevo cosi' fare uno script che mi permettesse di fare questo eseguendo un unico comando su di un unica postazione...

Il discorso del sync era solo un esempio... quello e' sicuramente fattibile col cron...
_________________
..:[DiGu]:.
Back to top
View user's profile Send private message
Dr.Dran
l33t
l33t


Joined: 08 Oct 2004
Posts: 766
Location: Imola - Italy

PostPosted: Sat Aug 26, 2006 8:24 am    Post subject: Reply with quote

Ciao, scusate se mi intrometto, ma per me la cosa + sensata può essere utilizzare DSH
Quote:
Distributed shell. Runs command through rsh or ssh on a cluster of machines. Requires libdshconfig to be already installed on the system.


La "Dancer"/Distributed shell non è particolarmente complicata da utilizzare e permette di aprire sia terminali che eseguire comandi simultanei su vari computers/clusters.

Cheers

Franco
_________________
:: [Dr.Dran] Details ::
- Linux User # 286282
- IT FreeLance Consultant
- President of ImoLUG [Imola & Faenza Linux User Group]
Back to top
View user's profile Send private message
gutter
Bodhisattva
Bodhisattva


Joined: 13 Mar 2004
Posts: 7162
Location: Aarau, Aargau, Switzerland

PostPosted: Sat Aug 26, 2006 10:59 am    Post subject: Reply with quote

... o in alternativa anche pconsole.
_________________
Registered as User #281564 and Machines #163761
Back to top
View user's profile Send private message
Dr.Dran
l33t
l33t


Joined: 08 Oct 2004
Posts: 766
Location: Imola - Italy

PostPosted: Sat Aug 26, 2006 12:16 pm    Post subject: Reply with quote

heylà Ciao Gutter!!!

beh si anche se pconsole è destinato + a un aspetto di console management a comunque è validissomo e comodissimo :wink:

Cheers

Franco
_________________
:: [Dr.Dran] Details ::
- Linux User # 286282
- IT FreeLance Consultant
- President of ImoLUG [Imola & Faenza Linux User Group]
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) Forum di discussione italiano All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum