#!/bin/sh #./test.sh test1 192.168.0.1 command=$1 host=$2 test1 () { echo "$host test1" #ssh -n ${host} hostname } test2 () { echo "$host test2" #ssh -n ${host} hostname } ${command}
./test.sh test1 192.168.0.1
#!/bin/sh #./test2.sh test1 host.lst command=$1 hostlist=$2 test1 () { echo "$host test1" #ssh -n ${host} hostname } test2 () { echo "$host test2" #ssh -n ${host} hostname } for host in `cat ./${hostlist}` do ${command} done
# cat host.lst 192.168.0.1 192.168.0.2 # ./test2.sh test1 host.lst 192.168.0.1 test1 192.168.0.2 test1 #
ssh -n 192.168.0.10 sudo "bash -c 'sed s/192.168.100.10/192.168.50.10/g /etc/hosts > /etc/hosts.20121111' " ssh -n 192.168.0.10 "sudo su - -c '/tmp/tmp.sh >> /tmp/2013052.txt && diff /tmp/20130501.txt /tmp/20130502.txt'" ssh -t 127.0.0.1 sudo /etc/init.d/httpd restart