NextPVR Forums

Full Version: PostProcessing help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I was attempting to add a condition to PostProcessing.sh to prevent comskip from running on recordings from a certain channel.

My PostProcessing script is
Code:
ffmpeg -i "$1" -vcodec copy -acodec copy -f matroska -| ffmpeg -i pipe: -codec copy -movflags faststart -y "${1%.*}.mp4" > /dev/null
if ["$2" -ne "32.*"]
then
nice -n 19 comskip --ini=/home/rex/Comskip/comskip.ini "$1" > /dev/null
fi
The mux part works fine but when it gets to the if statement this output from the log is what I get
Code:
> /var/opt/nextpvr/scripts/PostProcessing.sh: line 2: [7.3: command not found
I am missing something but I don't know what it could be.

Any help is much appreciated.
I thought -ne was for integers and it looks like you are missing a semicolon, maybe try

if [["$2" != "32."*]] ; then

When sub added linux support I told him I was worried about extra support time, which seems to be the case these days. I really suggest you look for helpful linux forums since I personally am going to simply ignore posts like this in the future. Maybe someone else here will help too.

Martin
Generally, in bash, you'd want spaces around the brackets.  So, maybe something like
Code:
if [[ "$2" != "32."* ]] ; then

You might need to use a regular expression

Code:
if [[ ! $2 =~ 32\.[0-9]* ]]; then
Remember that in a regular expression (regex), a period matches any character if it is not escaped with the backslash.  Also, "[0-9]" matches any digit and "[0-9]*" matches any number of digits.

I highly recommend testing your logic from a command line or short script executed from a command line.  Something like "if [ something ]; then echo 'yes'; else echo 'no'; fi".  Play around with "something" until you get yes and no in every expected situation.
Thanks for the help!

This is working for me. 
Code:
if [[ "$2" != "32."* ]]; then nice -n 19 comskip --ini=/home/rex/Comskip/comskip.ini "$1" > /dev/null; fi
Just as an FYI with anyone trying to get the right RegEx for their need, I use this site, which let's you put in a blob of text and the create a RegEx. It shows results real time, so you know if you're making it better or worse.

https://regexr.com