[2011-09-22] 通过多次ssh部署文件到服务器的脚本

用于将写好的程序部署到服务器

file: cplab
#!/bin/sh

if [ ! $1 ]
then
	echo 'err: no input file'; exit
fi

HOSTNAME=$(hostname)

if [ "$HOSTNAME" = 'rush-Vostro-1400' ]
then
	dest='rush@mylab'
	echo "copy from $HOSTNAME to $dest"
	scp $1 'cplab' $dest:~/gao/
	echo 'done'
	ssh $dest "sh ~/gao/cplab $1"
fi

if [ "$HOSTNAME" = 'rush-desktop' ]
then
	dest='[email protected]'
	echo "copy from $HOSTNAME to $dest"
	scp "/home/rush/gao/$1" "/home/rush/gao/cplab" $dest:~/gao/
	echo 'done'
	ssh $dest "sh ~/gao/cplab $1"
fi

if [ "$HOSTNAME" = 'yq-fx-svr1' ]
then
	dest='[email protected]'
	echo "copy from $HOSTNAME to $dest"
	scp "/home/yqjc/gao/$1" "/home/yqjc/gao/cplab" $dest:~/gao/
	echo 'done'
fi

你可能感兴趣的:(shell)