在 bash 脚本/命令中,如何使 PC 发出哔哔声或播放声音文件? [英] In a bash script/command how can I make a PC beep noise, or play a sound file?

查看:17
本文介绍了在 bash 脚本/命令中,如何使 PC 发出哔哔声或播放声音文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些长时间运行的脚本需要输入/交互才能继续,但是当我切换到另一个窗口时,我希望收到通知(通过声音)任务已完成,现在正在等待输入.

I have some long running scripts with breaks requiring input/interaction to continue but when I switch to another window I'd like to be notified (by sound) that a task is complete and now awaiting input.

我希望能够播放音频剪辑(*.mp3、*.ogg 等),但不关心是否唯一的解决方案是使 PC 扬声器发出哔哔声.

I would prefer to be able to play an audio clip (*.mp3, *.ogg, etc.) but wouldn't care if the only solution is to make the PC Speaker beep noise.

有什么想法吗?我对任何可以安装播放声音的 CLI 实用程序持开放态度,然后我可以在需要时执行.

Any ideas? I'm open to any CLI utilities I can install that play sounds that in turn I can execute when needed.

仅供参考:我的系统正在运行 WinXP Pro.

FYI: My System is running WinXP Pro.

更新:哦!我的 Windows > 控制面板 > 声音 > 默认提示音:设置为 (无).咕噜噜...

UPDATE: Doh! My Windows > Control Panel > Sounds > Default Beep: was set to (none). Grrr...

问题解决了.

推荐答案

试试这个:

回声^G

(^G是ctrl+G得到的)

(^G is obtained by ctrl+G).

注意:您不能将此代码复制并粘贴到批处理文件中,这将不起作用.要获取文件中的 ^G 字符,请在 cmd 窗口中键入:

Note: you can't copy and paste this code in a batch file, it won't work. To obtain a ^G character in a file, type in a cmd window:

echo ^G > beep.txt

echo ^G > beep.txt

(再次,^G 是通过 ctrl+G 获得的).

(again, ^G is obtained by ctrl+G).

然后你就会有一个名为beep.txt的文件,用记事本打开它,会有一个方形字符.保存在文件中后,这是我们的 ^G.

Then you'll have a file named beep.txt, open it with notepad, there will be a square character. This is our ^G once it is saved in a file.

然后您可以将其复制并粘贴到批处理文件中以发出声音(不要忘记在其前面加上echo").

You can then copy and paste it in a batch file to make a sound (don't forget to put "echo" in front of it).

这篇关于在 bash 脚本/命令中,如何使 PC 发出哔哔声或播放声音文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆