在 .sh 文件中运行时未找到 wait-for-it 命令

发布于 2025-01-16 14:31:22 字数 494 浏览 0 评论 0原文

假设我正在执行一个名为 run.sh 的文件。我在此文件中有以下命令:

SERVER=${SERVER:-"localhost:5555"}
wait-for-it ${SERVER}

当我 echo ${SERVER} 时,我可以看到它已正确设置为 newserver:5555 。当我运行 run.sh 文件时,出现此错误:

Command 'newserver:5555' not found

我做错了什么?

更新:“wait-for-it 是一个等待可用性的脚本在执行用户定义的命令之前,先检查一个或多个 TCP 服务(即主机:端口)。”

Say I'm executing a file named run.sh. I have this commands inside this file:

SERVER=${SERVER:-"localhost:5555"}
wait-for-it ${SERVER}

When I echo the ${SERVER}, I can see that it is correctly set to newserver:5555. When I run run.sh file, I get this error:

Command 'newserver:5555' not found

What am I doing wrong?

UPDATE: "wait-for-it is a script that will wait on the availability of one or more TCP services (i.e. host:port) before executing a user-defined command."

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

等风来 2025-01-23 14:31:22

从您链接的 wait-for-it 网站

Usage: wait-for-it [OPTIONS] [COMMANDS]...

  Wait for service(s) to be available before executing a command.

Options:
  -h, --help               Show this message and exit.
  -v, --version            Show the version and exit.
  -q, --quiet              Do not output any status messages
  -p, --parallel           Test services in parallel rather than in serial
  -t, --timeout seconds    Timeout in seconds, 0 for no timeout  [default: 15]
  -s, --service host:port  Services to test, in one of the formats: ':port',
                           'hostname:port', 'v4addr:port', '[v6addr]:port' or
                           'https://...'

所以您可能想要:

SERVER=${SERVER:-"localhost:5555"}
wait-for-it --service ${SERVER}

From the wait-for-it website that you linked:

Usage: wait-for-it [OPTIONS] [COMMANDS]...

  Wait for service(s) to be available before executing a command.

Options:
  -h, --help               Show this message and exit.
  -v, --version            Show the version and exit.
  -q, --quiet              Do not output any status messages
  -p, --parallel           Test services in parallel rather than in serial
  -t, --timeout seconds    Timeout in seconds, 0 for no timeout  [default: 15]
  -s, --service host:port  Services to test, in one of the formats: ':port',
                           'hostname:port', 'v4addr:port', '[v6addr]:port' or
                           'https://...'

So you probably want:

SERVER=${SERVER:-"localhost:5555"}
wait-for-it --service ${SERVER}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文