月度归档:2016年04月

shell的登陆交互

#!/bin/bash
# test.sh user pw
if [ ! $# -eq 2 ] ; then
echo “请输入用户名和密码以空格分开!”
exit

else
name=”$1″
passwd=”$2″
fi

cat hosts | while read hosts
do

echo “正在$hosts上用户$name”
expect <” {
send “enable\r” ;exp_continue
}
}
EOF
echo “成功建立”
done