在 systemd 启动期间访问 stdin

发布于 2024-12-27 23:59:28 字数 400 浏览 4 评论 0原文

我有一个脚本,在启动计算机时请求用户输入数字。该计算机运行的是 Fedora 16。它在 Fedora 13 上使用过工作,但升级后

read INTEGER

立即返回,没有捕获任何用户输入。我尝试过

read INTEGER
wait $!

,但(可以预见)这也行不通。该脚本从 systemd 服务文件运行(请参阅下面的注释)。它必须以root身份运行,并且必须在用户登录之前启动。它当前调用bash作为其解释器,但通过一些努力,这可以改变。任何人都可以帮助恢复此脚本正常吗?

额外加分:在 F13 中,它用于停止用户输入的启动(根据需要),但在用户键入时不会显示输入。有没有办法添加这个功能?

I have a script which solicits a numeric input from the user while booting the computer. The computer is running Fedora 16. It used work, on Fedora 13, but after the upgrade

read INTEGER

returns immediately, without catching any user input. I tried

read INTEGER
wait $!

but (predictably) that too doesn't work. The script is run from a systemd service file (see comments below). It must be run as root, and must started before the user logs in. It currently calls bash as its interpreter, but with some effort, that could be changed. Can anyone help return this script to normal?

Extra credit: In F13, it used to halt booting for user input (as desired) but the input was not displayed as the user typed. Is there a way to add this functionality?

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

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

发布评论

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

评论(1

随梦而飞# 2025-01-03 23:59:28

在正常启动期间,键盘连接到 Plymouth(我相信)

在 Fedora 上,我相信您想要类似的东西:

 plymouth ask-question --prompt="Pick a number between 0 and ∞" \
     --command="/usr/bin/numberguesser"

可能

     --dont-pause-progress

应该 显示 Plymouth 提示屏幕,与加密文件系统的方式没有什么不同提示输入密码。

请注意,/usr/bin/numberguesser 只会在其标准输入上获取通过管道输入的字符串。

未经测试,抱歉:-(

During a normal boot, the keyboard is connected to Plymouth (I believe)

On Fedora, I believe you want something like:

 plymouth ask-question --prompt="Pick a number between 0 and ∞" \
     --command="/usr/bin/numberguesser"

possibly with

     --dont-pause-progress

That should display the Plymouth prompt screen, not dissimilar from the way that crypto filesystems prompt for their passwords.

Note that /usr/bin/numberguesser would only get the string entered piped in on its standard input.

Untested, sorry :-(

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