当前位置:  开发笔记 > 编程语言 > 正文

Port Bash批处理

如何解决《PortBash批处理》经验,为你挑选了1个好方法。

在我的学校,我希望自动化告诉学生上课,并在午餐结束前五分钟开始播放一首歌.

我写了一个Bash脚本来播放这个宣告,一首随机的歌曲.五分钟后,剧本将淡出音乐并杀死VLC.我需要在Windows上运行此脚本,因为它是用于公告的操作系统.它不需要是批处理,但我必须能够在Windows上运行它.

这是我写的脚本:

#!/bin/bash
#Copyright (c) 2010, Jason Cook
#All rights reserved.

#Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

 #Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
 #Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
 #Neither the name of the Jason Cook  nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#Set Arguments
song=$((RANDOM % 21))
volume_fade_counter=0

echo "Released under The BSD License"
echo

echo "11:55"
echo "Playing \"Get to Class\""
echo "Playing song number $song"
vlc /home/jason/Documents/Announcements-Lunch/get-to-class.mp3 /home/jason/Documents/Announcements-Lunch/$song.mp3 &

echo "Waiting for five minutes"
sleep 360

echo "Fading audio"
while [ $volume_fade_counter -le 100 ] ; do
 aumix -v -1
 volume_fade_counter=$(( $volume_fade_counter + 1 ))
done

echo "Killing VLC"
pkill vlc
exit

enzotib.. 5

看看Cygwin,这是一个基于Windows的免费UNIX层,提供了大量的软件包.它包括bash直接运行bash脚本.



1> enzotib..:

看看Cygwin,这是一个基于Windows的免费UNIX层,提供了大量的软件包.它包括bash直接运行bash脚本.

推荐阅读
依然-狠幸福
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有