|
标题: glc小组成员注意:CVS自动输入密码脚本。
由于glc的cvs系统用ext方式,使得我们无法像pserver那样用cvs login一次性登录,给我们的维护工作带来了不便,虽然说这样更安全。所以我写个这两个脚本。
是用方法:
1.将这两个脚本拷贝到你的cvs目录下面。
2.修改脚本glc_cvs的script_dir变量为你存放这两个脚本的目录。
3.
代码:
$source glc_cvs
$cvs login
输入密码
和正常的cvs一样操作
提示:为了安全起见在你离开电脑后,输入cvs logout 退出!!!
依赖性:需要安装expect!
脚本源码:
PHP 代码:
xiaosuo@center cvs $ cat autocvs
#!/usr/bin/expect -f
###
###the args[0]=PassWord args[1]... is the CVS arguments
###
set timeout 300
set args [lindex $argv 1]
spawn $env(script_dir)/glc_cvs true $args
expect {
"Password:" { send "[lindex $argv 0]\r" }
timeout { puts "Timeout while connect to the server\n"; exit }
}
expect timeout { puts "Timeout while wait for the answer\n"; exit }
PHP 代码:
xiaosuo@center cvs $ cat glc_cvs
#!/bin/bash
###
###Set the environment of the GLC CVS and the AUTOMTIC COMMANDS
###If you think this is not security enough you can't use this script ~_~
###But I encourage you to use it because it is HELPFUL
###
#redefine the cvs command
function cvs()
{
if [ X$1 = Xlogin ] ; then
stty -echo
while [ X$PassWord = X ]
do
echo -n "Please input you password for GLC CVS:"
read PassWord
done
stty echo
elif [ X$1 = Xlogout ] ; then
unset PassWord
unset script_dir
echo "Thanks for use this script"
exit
elif [ X$PassWord = X ] ; then
echo "Please Login with the command \"cvs login\"!"
elif [ X$1 = Xtrue ] ; then
shift
echo $@
/usr/bin/cvs $@
exit
elif [ $# -ne 0 ] ; then
$script_dir/autocvs $PassWord "$*"
fi
}
#the autocvs recall this script, so add this line
cvs $@
#set the CVS variables
export CVSRSH=ssh
export CVSROOT=:ext:glc@www.magiclinux.org:/sfroot/home/groups/glc/cvsroot
#set the scripts variables
unset PassWord
unset script_dir
script_dir="/home/xiaosuo/work/cvs"
export PassWord
export script_dir
echo "Setup the Environment successfully!"
__________________
Unix Program = Framework + Components
-----------------------------------------------------
My blog: http://xiaosuo.cublog.cn
此帖于 04-12-01 00:57 被 小锁 编辑.
|