0

I'm trying to execute a script that runs a Handbrake video conversion.

If I run the following command from the terminal, it works fine:

HandbrakeCLI -i inputtestfile.mp4 -o outputtestfile.mp4 -z "Preset"

If I put this into a .sh script (and give the script execution rights using chmod a+x), I get the following error:

HandbrakeCLI: Command not found

If I then put the full path to HandbrakeCLI, it then works, for example:

/usr/local/Cellar/handbrake/1.2.0/bin/HandBrakeCLI -i inputtestfile.mp4 -o outputtestfile.mp4 -z "Preset"

However, the above method is inconvenient because every time I update Handbrake to a new version, I'll have to update the script.

How can I add Path (I think this is right), to the script, so I can just use:

HandbrakeCLI -i inputtestfile.mp4 -o outputtestfile.mp4 -z "Preset"

Thanks

HaveAGitGat
  • 59
  • 1
  • 9

1 Answers1

0

You can begin the .sh script with:

PATH=$PATH:/usr/local/Cellar/handbrake/1.2.0/bin

is an environment variable that affects where would look unqualified files names (commands) from.

And for the changing version you can parse HandBrake --version output and use it as a variable instead of 1.2.0 string in PATH.

  • thanks for the help. Some helped me solve it using "/usr/local/bin/HandBrakeCLI" – HaveAGitGat Jan 27 '19 at 05:06
  • You're welcome; but are you sure that file is not being a symbolic link to the path above (which will still be affected by versioning)? –  Jan 27 '19 at 10:09