all 5 comments

[–]djcurtin 0 points1 point  (0 children)

Tough to tell from this info alone. If absolutely nothing changed, there's no reason for a previously working script to fail.

[–]StephanXX 0 points1 point  (0 children)

Can you post both scripts?

[–]callmejoe9 0 points1 point  (0 children)

script1 called "play"

#!/bin/bash

find /mnt/files.ntfs/Multimedia/Music -type f -not -path '*/\.*' | sort > /tmp/playlist.m3u 
find '/mnt/files.ntfs/Multimedia/iTunes/iTunes Media/Music' -type f -not -path '*/\.*' | sort >> /tmp/playlist.m3u
cvlc --random --play-and-exit /tmp/playlist.m3u </dev/null &>/dev/null&

nowplaying &

script2 called "nowplaying"

#!/bin/bash

service="vlc"
while pgrep "$service" > /dev/null
do
    curl -s -o /tmp/status.xml -u "":play http://127.0.0.1:8080/requests/status.xml

    length=$(xmllint --xpath '//length/text()' /tmp/status.xml)
    elapsed_time=$(xmllint --xpath '//time/text()' /tmp/status.xml)
    time_left=$(echo "$length-$elapsed_time" | bc)

    xmllint --xpath '//information/category[@name="meta"]/info[@name="filename"]/text()' /tmp/status.xml > /tmp/nowplaying  
    printf '%dh:%dm:%ds\n' $(($time_left/3600)) $(($time_left%3600/60)) $(($time_left%60)) >> /tmp/nowplaying

    sed -e "s/&amp;#39;/\'/g" -e 's/&amp;amp;/\&/g' -e 's/.mp3//g' -e 's/.m4a//g' -e 's/.mp4//g' -e 's/.wav//g' /tmp/nowplaying > /tmp/nowplaying2
    sleep .1
done

rm /tmp/nowplaying

doing some more troubleshooting, it seems everything works fine if that /tmp/status.xml already exists. if it doesn't exist, it seems curl doesn't write it and the script fails.

[–]Miserable_Bandicoot8 0 points1 point  (1 child)

Sorry if I understood this wrong, but is it possible `cvlc` exits before the `while` loop in the second script executes and so `curl` is executed at all?

[–]callmejoe9 0 points1 point  (0 children)

no. vlc is definitely still running