如何停止用户输入在交互式终端窗口上显示?

发布于 2025-02-12 01:44:55 字数 300 浏览 0 评论 0原文

这是脚本的示例:

while true; do 
printf ""
done

现在,如果我在交互式终端上运行此脚本,它显然什么也没打印!

但是,在同一情况下,如果我也开始键入字符从我的键盘上键入,他们显然会在脚本交互式运行时在终端窗口上显示。

示例输出:

fasd^[[D^[[A^[[Cfsf

我想暂时停止用户输入在脚本仍在运行时显示。

谢谢您的任何帮助。

Here is an example of script:

while true; do 
printf ""
done

Now if I run this script on a interactive terminal it obviously print nothing!

but in same case if I also start typing CHARACTERS and KEYS from my keyboard they will obviously show on terminal window while the script is running interactively.

Example output:

fasd^[[D^[[A^[[Cfsf

I want to temporarily stop user input to show while script is still running.

Thankyou, for any help.

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

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

发布评论

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

评论(1

花伊自在美 2025-02-19 01:44:55

在我的

...
COF='\e[?25l' #Cursor Off
CON='\e[?25h' #Cursor On

cursor () {
    case $1 in
         on) stty  echo; printf "$CON";;
        off) stty -echo; printf "$COF";;
    esac
}
...

cursor on
cursor off
...

In my piu-piu project I'm switching user input on and off like this:

...
COF='\e[?25l' #Cursor Off
CON='\e[?25h' #Cursor On

cursor () {
    case $1 in
         on) stty  echo; printf "$CON";;
        off) stty -echo; printf "$COF";;
    esac
}
...

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