Skip to content

Instantly share code, notes, and snippets.

@hyounggyu
Created April 9, 2013 04:00
Show Gist options
  • Select an option

  • Save hyounggyu/5342856 to your computer and use it in GitHub Desktop.

Select an option

Save hyounggyu/5342856 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Unknown Author.
HOSTLISTFILE="$HOME/.hosts"
#Error display function
Error_Show() {
case "$1" in
1) echo 'Usage : psh node[,node] command';;
2) echo "psh:Hostlist file not exist";;
*) echo 'psh:Unknow 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
# rsh "$NAME" $* >&1 2>&1|sed "s/^/"`echo $NAME|cut -f 1 -d '.'|cut -c -10`:" /g"
ssh -q -x "$NAME" $* >&1 2>&1|sed "s/^/"`echo $NAME|cut -f 1 -d '.'|cut -c -13`:" /g"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment