À mon école, je veux automatiser le processus consistant à dire aux élèves d'aller en classe et de jouer une chanson cinq minutes avant le début des cours à la fin du repas.Port Bash to Batch
J'ai écrit un script Bash qui va jouer l'annonce, une chanson aléatoire. Après cinq minutes, le script va éteindre la musique et tuer VLC. J'ai besoin que ce script tourne sous Windows car c'est le système d'exploitation utilisé pour les annonces. Il n'a pas besoin d'être Batch, mais je dois pouvoir l'exécuter sur Windows.
Voici le script que j'ai écrit:
#!/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
Quels sont les problèmes spécifiques que vous avez avec le portage? Avez-vous besoin de conseils sur les outils à utiliser? Il est peu probable que les utilisateurs de StackOverflow portent simplement votre script, mais nous vous aidons avec des questions et des problèmes spécifiques. – DarkDust
Les problèmes que je suis ne sachant pas le premier penser à Batch. Si quelqu'un m'a dit comment faire disparaître le son et attendre que VLC commence cinq minutes avant de passer à l'étape suivante. Je n'ai pas posté cette attente que les gens à porto cela pour moi (mais ce serait incroyable), j'ai posté cela pour de l'aide sur Batch. – Jason
Vous pouvez sauvegarder '$!' Après avoir lancé vlc en arrière-plan pour être sûr de tuer le bon processus. (Voir "Paramètres spéciaux" dans la page de manuel de bash.) –