#!/bin/sh

HOSTLISTFILE="/usr/local/bin/hadoop"

#Error display function
Error_Show() {
 case "$1" in
  1) echo 'Usage: psh node[,node] command';;
  2) echo "psh::Hostlist file not exist";;
  *) echo 'psh:Unknown Error';;
 esac
 exit 1
}

[ "$#" -lt "2" ]&&Error_Show 1
[ ! -f "$HOSTLISTFILE" ]&&Error_Show 2

NODELIST=$(cat "$HOSTLISTFILE" | egrep $(echo $1 | sed "s/,/|/g") | awk '{print $1}')
shift
for NAME in $NODELIST
do
 ssh -q -x "$NAME" $* >&1 | sed "s/^/"`echo $NAME|cut -f 1 -d '.' | cut -c -15`:" /g"
done

'Linux' 카테고리의 다른 글

Shell Script TIPs  (0) 2024.11.29
vim TIPs  (0) 2022.01.10
FreeNX 실행시 에러 - Error: Can't determine the location of the X display socket.  (0) 2011.01.27
linux 백업/복구 후 selinux 처리  (0) 2010.10.14
Channel bonding  (0) 2010.10.11

+ Recent posts