LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1419|回复: 3

usleep的问题

[复制链接]
发表于 2006-3-5 12:22:38 | 显示全部楼层 |阅读模式
最近看别人的程序中的一个脚本,如下

#!/bin/sh

HOST=localhost
AGENTDIR=bs2k
COACHDIR=sputcoach
AGENT=artagent/BS2kAgent
COACH=SputCoach
AGENTOPT="-log_dir /tmp -host $HOST"
COACHOPT="-server_9.4 0 -host $HOST"

# sleep in between agent starting if available
USLEEP=`which usleep`
if [ "$USLEEP" != "" ]; then
  USLEEP=$[color="Red"]USLEEP\ 300000
else
  echo "WARNING: No usleep found on this system!"
fi

cd ..
BASEDIR=`pwd`

######## START AGENTS ###########

cd $AGENTDIR || exit 1

./$AGENT -goalie $AGENTOPT $DBG &
sleep 1

I=0
while [ "$I" != "10" ] ; do
  ./$AGENT $AGENTOPT $DBG &
  $USLEEP
  I=`expr $I + 1`
done

######## START COACH ##########
cd $BASEDIR
cd $COACHDIR || exit 1

./$COACH $COACHOPT $DBG &

我的机器上面没有usleep,导致WARNING: No usleep found on this system!

请问怎么安装usleep。我google了一下,发现usleep最多的介绍是作为函数介绍的,而不是命令。 但上面的脚本则明显调用了usleep的命令,而的机器上正好没有。

谢谢各位
发表于 2006-3-5 13:35:36 | 显示全部楼层
我的系统上:
  1. [matt@localhost ~]$ usleep
  2. [matt@localhost ~]$ whereis usleep
  3. usleep: /bin/usleep /usr/share/man/man3/usleep.3.gz /usr/share/man/man3p/usleep.3p.gz /usr/share/man/man1/usleep.1.gz
  4. [matt@localhost ~]$ rpm -qf /bin/usleep
  5. initscripts-8.11.1-1
  6. [matt@localhost ~]$ man usleep
  7. [matt@localhost ~]$ man usleep |cat
  8. USLEEP(1)                                                            USLEEP(1)
  9. NAME
  10.        usleep - sleep some number of microseconds
  11. SYNOPSIS
  12.        usleep [number]
  13. DESCRIPTION
  14.        usleep sleeps some number of microseconds.  The default is 1.
  15. OPTIONS
  16.        --usage Show short usage message.
  17.        --help, -?
  18.               Print help information.
  19.        -v, --version
  20.               Print version information.
  21. BUGS
  22.        Probably  not accurate on many machines down to the microsecond.  Count
  23.        on precision only to -4 or maybe -5.
  24. AUTHOR
  25.        Donald Barnes <djb@redhat.com>
  26.        Erik Troan <ewt@redhat.com>
  27.                                  Red Hat, Inc                        USLEEP(1)
  28. [matt@localhost ~]$
复制代码
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-3-11 21:06:41 | 显示全部楼层
我用的是ubuntu5.04,输入usleep显示没有这个命令,但是有sleep这个命令

所以请问怎样添加usleep?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-3-13 22:57:35 | 显示全部楼层
我可以做一个usleep的连接指向sleep吗?

它们的功能挺类似的
回复 支持 反对

使用道具 举报

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

本版积分规则

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