Last active
November 9, 2016 16:03
-
-
Save jamespfinn/5766ba4946453fdb10a1ceef29c6b7c2 to your computer and use it in GitHub Desktop.
This wrapper script will fork castnow. It accepts all castnow options and forks the process to the background.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 2016.10.08 - jamespfinn@gmail.com | |
# https://github.com/jamespfinn | |
# | |
# This script will fork an instance of castnow (https://github.com/xat/castnow). | |
# All options passed to this script will be passed to castnow | |
# e.g.: | |
# $ ./castnow-fork.sh file1.mp3 file2.mp3 --address 192.168.1.44 | |
# | |
# This script has only been tested on Linux | |
# To make it work on OSX the output from 'ps' needs to be handled differently. | |
# See https://github.com/xat/castnow/issues/169#issuecomment-259262796 for the | |
# necessary modifications. | |
# | |
OUT1=/tmp/castnow-fork.out | |
OUT2=/dev/null | |
set -m | |
{ | |
{ castnow $@ &>$OUT1 ; } & | |
export pid=$! | |
( | |
while kill -0 $pid ; do | |
if [ "$(ps -o stat -p $pid | tail -1 | cut -c1)" == "S" ]; then | |
{ | |
echo killing $pid... | |
kill $pid | |
} | |
fi | |
done | |
) | |
} &> $OUT2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment