0

I have made a script which does mux a videofile, multiple audiofiles and multiple subtitles into one .mkv.

the script tries to run:
"/usr/bin/mkvmerge" -o "test.mkv" "--default-track" "0:yes" "--forced-track" "0:no" "--display-dimensions" "0:853x462" "-d" "0" "-A" "-S" "-T" "(" "mux.mkv" ")" "--language" "0:eng" "--default-track" "0:yes" "--forced-track" "0:no" "--no-global-tags" "--no-chapters" "-a" "0" "-D" "-S" "-T" "(" "test_eng_1.opus" ")" "--default-track" "0:no" "--forced-track" "0:no" "--no-global-tags" "--no-chapters" "-a" "0" "-D" "-S" "-T" "(" "test_und_2.opus" ")" "--language" "0:eng" "--default-track" "0:no" "--forced-track" "0:no" "--no-global-tags" "--no-chapters" "-s" "0" "-D" "-A" "-T" "(" "test_eng_3.idx" ")" "--language" "0:fra" "--default-track" "0:no" "--forced-track" "0:no" "--no-global-tags" "--no-chapters" "-s" "0" "-D" "-A" "-T" "(" "test_fra_5.idx" ")" "--language" "0:spa" "--default-track" "0:no" "--forced-track" "0:no" "--no-global-tags" "--no-chapters" "-s" "0" "-D" "-A" "-T" "(" "test_spa_4.idx" ")" "--title" "test"

If I run the script it shows: line 214: (the stuff above): No such file or directory

If I copy and paste the output and run it in bash all runs OK:

mkvmerge v7.7.0 ('Six Voices') 64bit built on Mar  3 2015 16:43:14 ... 
Muxing took 3 seconds.

Here is the part of the script which tries to run mkvmerge:

213 mux="\"/usr/bin/mkvmerge\" -o \"$gname.mkv\" $muxvideo$muxaudio$muxsub$tacks$title"
214 "$mux"

Why does it run in the terminal but not in the script?

  • You appear to be mixing/comparing apples and some other kind of fruit. You're not doing the same thing in the terminal and in the script, are you? Did you type mux="\"/usr/bin/mkvmerge\" -o …" and then "$mux"? Why are you assigning the entire command to a variable like that (in the script)? Just do the same thing in the script that works in the terminal. – G-Man Mar 20 '15 at 3:08
1

Your script defines a variable mux with its value being the big long mkvmerge command you pasted, literally with all those double quotes and everything: notice how the double quotes are backslash-escaped so that they get included literally in the string.

Then it does:

"$mux"

Which tries to run a command named after the contents of that variable, spaces and quotes and all. Since there is no command called "/usr/bin/mkvmerge" -o "test.mkv" "--default-track" etc..., you get the error.

Are you sure that line shouldn't be this?

eval "$mux"

...which would parse the contents of $mux as a shell command line, thus interpreting all those spaces and double quotes as shell syntax instead of treating it literally?

Or much more simply... just execute mkvmerge with all the right arguments without first building a quoted command and stuffing it into a variable and then executing the variable as a command.

  • Thanks, that was it... had no clue :) My first big script :))) – Eliot Mar 20 '15 at 3:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.