QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1514|回复: 5

谁能帮我解释一下这个shell小程序

[复制链接]
发表于 2006-6-16 09:32:49 | 显示全部楼层 |阅读模式
echo ' example for until '
echo ' the shell wait until another user whose login name we pass on the command line logs on'

until who | grep "$1" > /dev/null
do
    sleep 60
done

echo -e \\a

我telnet到一台计算机上,运行这个程序后就退出了,为什么?
发表于 2006-6-16 10:17:08 | 显示全部楼层
怎么运行的?
执行这个脚本?
回复

使用道具 举报

 楼主| 发表于 2006-6-16 10:21:14 | 显示全部楼层
我telnet到一台机器上,然后在那台机器上运行“. aaa.sh”
回复

使用道具 举报

发表于 2006-6-16 11:29:02 | 显示全部楼层
" echo ' example for until '
echo ' the shell wait until another user whose login name we pass on the command line logs on' "

until 的例子
该脚本一直等到一个与传给脚本参数一样的用户名登录为止

你加参数了吗?
回复

使用道具 举报

 楼主| 发表于 2006-6-16 11:32:39 | 显示全部楼层
我没加参数,/dev/null 是什么意思
回复

使用道具 举报

发表于 2006-6-16 11:50:51 | 显示全部楼层
正确用法应该是 ./aaa.sh  xxx
xxx为一用户名,该用户登录时,该脚本退出
/dev/null 为一null设备, 就是 所有输入都被废弃掉.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-9-30 08:50 , Processed in 0.042889 second(s), 16 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表