如何在shell用写指令让它退出登录?

谢谢版主对我的帮助,向你致敬.      
复制内容到剪贴板
代码:
[color=blue][user@host tmp] #[/color] cat /home/foo/.bashrc
# .bashrc

source bar.sh
[color=blue][user@host tmp] #[/color] cat /home/foo/bar.sh

echo "Logging out ..."
sleep 2
exit
[color=blue][user@host tmp] #[/color] telnet localhost
Trying 127.0.0.1...
Connected to localhost (127.0.0.1).
Escape character is '^]'.
. . . . . .
Kernel 2.4.21-20.0.1.ELsmp on an i686
login: foo
Password:
Last login: Tue Apr 12 02:04:32 from localhost
Logging out ...

Connection closed by foreign host.
[color=blue][user@host tmp] #[/color]
      
[root--149--/home/aaa]cat .bashrc
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
sh 1.sh
[root--150--/home/aaa]cat 1.sh
echo "Logging out ..."
sleep 3
exit
[root--153--/home/aaa]telnet www.hellolinux.net
Trying 61.133.202.70...
Connected to www.hellolinux.net (61.133.202.70).
Escape character is '^]'.
                                                                                                               
Linux 2.4.21-4.ELsmp (nxgzserver) (16:04 on Tuesday, 12 April 2005)
                                                                                                               
login: aaa
Password:
Last login: Tue Apr 12 16:02:34 from 61.133.202.70
Logging out ...
[aaa@nxgzserver aaa]$ whoami
aaa
[aaa@nxgzserver aaa]$
你本机用户名是不是和telnet的用户名一样??所以最后一个提示符是在telnet,而不是本机中???      
不同系统可能有所差别吧      
[QUOTE=dearvoid]不同系统可能有所差别吧[/QUOTE]
root--149--/home/aaa]cat .bashrc
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
sh 1.sh
[root--150--/home/aaa]cat 1.sh
echo "Logging out ..."
sleep 3
exit
[root--153--/home/aaa]telnet www.hellolinux.net
Trying 61.133.202.70...
Connected to www.hellolinux.net (61.133.202.70).
Escape character is '^]'.

Linux 2.4.21-4.ELsmp (nxgzserver) (16:04 on Tuesday, 12 April 2005)

login: aaa
Password:
Last login: Tue Apr 12 16:02:34 from 61.133.202.70
Logging out ...
[aaa@nxgzserver aaa]$ whoami
aaa
[aaa@nxgzserver aaa]$
你本机用户名是不是和telnet的用户名一样??所以最后一个提示符是在telnet,而不是本机中???


斑竹,他退不出来是因为他用
“.......if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
sh 1.sh
[root--150--/home/aaa]cat 1.sh
echo "Logging....”
sh 1.sh等于fork了一个新的bash,里面的exit只是退出新的bash.而退不出telnet.要用
“source 1.sh”
欢迎大家交流哦
My blog:http://fingerling.tianyablog.com      
致敬!这么有耐心