DVR exit codes and PostScript Running

I’m setting up DVR to run a Postscript and getting and exit code, Anyone tell me where I can find more details on the exit codes?

May 29, 2017 14:07:04.695 [0x7f2597ffd700] ERROR - JobManager: child process returned: 8 (Exec format error)
May 29, 2017 14:07:04.695 [0x7f256dbf8700] ERROR - DVR:Recorder: Postprocessing script ‘/home/kevin/PlexPostProc/PlexPostProc.sh’ exited with error code 8.

The Script runs fine, manually on the ubunutu server…but seems to exit when run in postprocessing any help would be great.

Thanks in advance
Kev*

What does the file permission look like? Does only your account have permission to execute or does your account and the group that your account is in have permission to execute? Is the Plex user in the same group as your account? Not running Plex on Ubuntu but that is what I would look for if the script runs fine under my account but won’t run under Plex account.

Permissions on the DVR script are 4 -rwxrwxrwx 1 plex plex 2451 May 28 19:49 PlexPostProc.sh*

Script is mod’d version of https://github.com/nebhead/PlexPostProc/blob/master/PlexPostProc.sh:

if [ ! -z “$1” ]; then

The if selection statement proceeds to the script if $1 is not empty.

FILENAME=$1 # %FILE% - Filename of original file

TEMPFILENAME="$(mktemp)" # Temporary File for transcoding

echo “"
echo “Transcoding, Converting to H.265 w/Handbrake”
echo "

HandBrakeCLI -e x265 --encoder-preset veryfast -i “$FILENAME” -o “$TEMPFILENAME”

echo “"
echo “Cleanup / Copy $TEMPFILENAME to $FILENAME”
echo "

rm -f “$FILENAME”
mv -f “$TEMPFILENAME” “$FILENAME”
chmod 777 “$FILENAME” # This step may no tbe neccessary, but hey why not.

echo “Done. Congrats!”
else
echo “PlexPostProc by nebhead”
echo “Usage: $0 FileName”
fi

Double check that you have “#!/bin/sh” (without the quotes) as the very first line of the script.

Thanks Melevittfl but yes that on the first line i i just trimmed the comments from script so that it did not fill up the forum.
The script is fine if i run it manually ./PlexPostProc.sh (Path to media file)

Do I have to put anything in the script box to let it know the incoming file name as a variable?

Ah, sorry. Didn’t read that it ran fine when run manually…

‘/home/kevin/PlexPostProc/PlexPostProc.sh’

Two things I can thinks of… First, you mentioned that the script is owned by user plex, but does the plex user have permission to read and execute the /home/kevin/PlexPostProc directory? You could try moving the script to /usr/local/bin.

Second, maybe the file has some corrupt characters from copy and pasting. try running 'od -c PlexPostProc.sh | less" and see if there are any strange characters in the first lines. It should look like this:

`0000000 # ! / b i n / s h

i f [`

I’ve moved it out of the user directory to the main Plex directory to check and still failing the same way

your command

0000000

! / b i n / s h

* * *

0000020 * * * * * * * * * * * * * * * *
*
0000120 * * * * * * * * * * *

* *

0000140 * * * * * * * * * * * * * * * *
*
0000240 * * * * * * * * * * * *

Hmm.

0000000 **
** # ! / b i n / s h

* * *

Notice the bolded "
" character above. The line with #!/bin/sh should be the very first line but the script has a blank line at the top.

If fixing that doesn’t work, then maybe try to see where it’s running from and under what user by having it run the script below:

#!/bin/sh
echo "Current directory:"
pwd
echo "Current user:"
whoami

You know what melevittfl if I could reach through the internet i could kiss you right now!

Yes it was the
that was making the script exit with code 8 in log.
Thank you, your a star!!!

Ha!

Glad I could help.