Monday, July 30, 2012

no frills scp & execute command script

1000 machines need a file and a command run.
some machines are up. some are not.

first thing, pubkey them. done.

now, what to do about that file and the command?

my file is called, oh, file. it is in ~ . somewhere.
drop a file, say, computers in pwd.

first, check if the computers are alive. then drop the file. then run whatever's in the file.


for ip_addr in $(cat computers) ; do
  ping -q -c 1 $ip_addr && \ 
  scp -r ~/somewhere/file toor@$ip_addr:/tmp && \ 
  ssh -l toor $ip_addr "bash -c \"/tmp/file \""

if you work by the hour, then this script would make you useless. if you're salaried, go get some coffee.
Post a Comment