scripts

misc scripts and tools
git clone git://git.2f30.org/scripts
Log | Files | Refs

ssh-multi (460B)


      1 #!/bin/sh
      2 
      3 if [ $# -lt 1 ]; then
      4 	echo "usage: $(basename $0) <host...>" 1>&2
      5 	exit 1
      6 fi
      7 
      8 trap 'rm -f ${batch}; exit 1' 2
      9 batch=$(mktemp)
     10 
     11 echo "#!/bin/sh" >> ${batch}
     12 
     13 while read cmd; do
     14 	echo ${cmd} >> ${batch}
     15 done
     16 
     17 echo "echo Press any key to terminate console..." >> ${batch}
     18 echo "read -n 1" >> ${batch}
     19 chmod +x ${batch}
     20 
     21 while [ $# -gt 0 ]; do
     22 	scp ${batch} $1:/tmp
     23 	urxvt -e sh -c "ssh -t $1 '${batch}'"
     24 	ssh $1 "rm ${batch}"
     25 	shift
     26 done
     27 
     28 rm ${batch}