一个有用的shell脚本
Posted IT小不点
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了一个有用的shell脚本相关的知识,希望对你有一定的参考价值。
#!/bin/bash #if [ $1 -eq null ]; then # echo "please input params1!" # exit #fi #if [ $2 -eq null ]; then # echo "please input params2!" # exit #fi # type , $1 { scp, ssh }, src $2, dst $3 user=hadoop if [ "$3" != "" -a "$1" != "scp" ] ; then user=$3 fi if [ "$4" != "" ] ; then iplist=$4 else iplist=`cat /home/hadoop/gitclone/opshell/hadoop/machine.conf` fi for ip in $iplist;do echo "-----ops $ip -------------" if [ "$1" == "scp" ] ; then scp -r $2 [email protected]$ip:$3 elif [ "$1" == "ssh" ] ; then ssh [email protected]$ip "mkdir ~/.ssh | touch ~/.ssh/authorized_keys" cat ~/.ssh/id_rsa.pub | ssh [email protected]$ip "cat >> ~/.ssh/authorized_keys" ssh [email protected]$ip "chmod 700 ~/.ssh" elif [ "$1" == "cmd" ] ; then ssh [email protected]$ip "$2" fi done
以上是关于一个有用的shell脚本的主要内容,如果未能解决你的问题,请参考以下文章