I’ve had an odd issue getting a postprocessing script which to work on macOS.
I found that, with a slight modification (changing “sed -r” to “sed -E”), the plexEncode script would work but only if I ran it manually from Terminal. It wouldn’t work when run from Plex.
I eventually discovered that it couldn’t find mediainfo or HandbrakeCLI (but only when running from Plex) and got it working by changing the $(which mediainfo) and $(which HandBrakeCLI) to hardcoded paths to where they were installed. Which is odd, because it worked fine without that change when running from Terminal.
Does anybody have any idea why using which didn’t work when running from Plex, could it be using a different user or running under a context which can’t find those executables?
Edit: I found I could get it to work using which by adding the following line to the start of the script:
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
So, it seems that the issue was that Plex was running the script with a different PATH than when it is run interactively from Terminal.