在SystemD中启动服务时如何添加用户输入

发布于 2025-02-09 04:05:25 字数 232 浏览 1 评论 0原文

我有一个在SystemD中配置的服务,该服务运行二进制文件并不断运行。问题在于,运行此二进制文件后,您必须通过在终端中键入y来确认条款,并通过单击Enter对其进行验证。我无法通过此文件运行此文件,因为Systemctl状态在我看来是失败,因为缺乏验证。有人知道我如何运行此服务并自动接受终端中的条款吗?

I have a service configured in systemd that runs a binary file and it runs constantly. The problem is that after running this binary file, you have to confirm Terms&Conditions by typing y in the terminal and validating it by click Enter. I cannot run this file through this, because the systemctl status appears to me as failed, because of lack of validation. Does anyone know how I can run this service and automatically accept Terms in terminal?

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

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

发布评论

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

评论(2

霓裳挽歌倾城醉 2025-02-16 04:05:25

我以这样的方式弄清楚了:
我在usr/bin/bin中创建了.sh使用此内容:

#!/usr/bin/bash
yes | /home/marek/webcash/webminer

然后,我在systemd中创建了execstart:execstart:/path/path/ to/file.sh

现在起作用 - Systemd正在正确运行,日志记录,答案“是”仅在用户提示符出现时仅在二进制文件中输入一次。

I figured it out in such a way:
I created .sh file in usr/bin with this content:

#!/usr/bin/bash
yes | /home/marek/webcash/webminer

Then I created config file in systemd with ExecStart: /path/to/file.sh

and now it works - systemd is running correctly, the logs are logging, the answer "yes" was typed only once in binary file when the user prompt appeared.

梦一生花开无言 2025-02-16 04:05:25

我相信您也可以做类似的事情:

ExecStart=/bin/bash -c 'yes | /home/marek/webcash/webminer'

I believe you could also be able to do something like:

ExecStart=/bin/bash -c 'yes | /home/marek/webcash/webminer'
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文