VLC/CVLC bash 脚本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6732627/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
VLC/CVLC bash script
提问by Venky
I have a list of URLs, over which i need to run VLC in a bash script. For each URL, i wish to run VLC for a couple of minutes (some of them could be infinite netradio URLs) and know if VLC was able to play it successfully. How do I judge through a bash script whether VLC was able to play the URL ? I tried echoing $? (ie the return code), but it always gave me 0 irrespective of whether the URL was played or not. Please help !
我有一个 URL 列表,我需要在 bash 脚本中运行 VLC。对于每个 URL,我希望运行 VLC 几分钟(其中一些可能是无限的 netradio URL)并知道 VLC 是否能够成功播放它。如何通过 bash 脚本判断 VLC 是否能够播放 URL?我试过回显 $? (即返回代码),但无论 URL 是否被播放,它总是给我 0。请帮忙 !
Regards, Venky
问候,文基
回答by Jeff M
To determine if the video played or not find a message that reflects that it played and grep for it. Grep for messages that indicate failure. You can also use --vvv if you want to get more information. You will see that there are a few distinct messages that get displayed upon success or failure.
确定视频是否已播放,找到反映它已播放的消息并对其进行 grep。用于指示失败的消息的 Grep。如果您想获得更多信息,也可以使用 --vvv。您会看到成功或失败时会显示一些不同的消息。
Or I would pull the sources and grep for exit codes
或者我会拉取源代码和 grep 以获取退出代码
find . -name "*.c" | xargs grep "exit("
找 。-name "*.c" | xargs grep "退出("
Then you can get an idea of the exit codes.
然后您可以了解退出代码。
Good luck.
祝你好运。

