You are not logged in.

#1 2012-08-20 14:28:09

johannesg00
Member
Registered: 2010-11-30
Posts: 36

Bash Script Problem

Hello,

i'm trying to mux some audio/movie files into an mvk contrainer, but i have one problem... here is the code:
̣

#!/bin/bash

track_title="a b"
chapters="--chapters \"${track_title}/chapters.txt\""

mkvmerge -o "${track_title}.mkv" \
	 --title "${track_title}" \
	 $chapters

mkvmerge -o "${track_title}.mkv" \
	 --title "${track_title}" \
	 --chapters "${track_title}/chapters.txt"

The second command works fine, but the first doesn't...
Here's the error:

Fehler: Die Datei '"a' konnte nicht zum Lesen geöffnet werden.

(in english: error: could not open the file "'a')

Does anybody know why this isn't working?
Thank you for your help wink

Offline

#2 2012-08-20 16:07:09

sebcactus
Member
From: Germany
Registered: 2005-01-27
Posts: 277

Re: Bash Script Problem

Maybe try:

#!/bin/bash

track_title="a b"

chapters="--chapters \"${track_title}/chapters.txt\""
echo $chapters

echo mkvmerge -o "${track_title}.mkv" \
	 --title "${track_title}" \
	 $chapters
mkvmerge -o "${track_title}.mkv" \
	 --title "${track_title}" \
	 $chapters

echo mkvmerge -o "${track_title}.mkv" \
	 --title "${track_title}" \
	 --chapters "${track_title}/chapters.txt"
mkvmerge -o "${track_title}.mkv" \
	 --title "${track_title}" \
	 --chapters "${track_title}/chapters.txt"

It should show you where you get the extra "

Offline

#3 2012-08-20 16:14:30

sebcactus
Member
From: Germany
Registered: 2005-01-27
Posts: 277

Re: Bash Script Problem

Actually I think the extra \" are the problem in your definition of chapters.

Offline

#4 2012-08-20 16:17:26

johannesg00
Member
Registered: 2010-11-30
Posts: 36

Re: Bash Script Problem

Hello wink

#!/bin/bash

track_title="a b"
chapters="--chapters \"${track_title}/chapters.txt\""

echo mkvmerge -o "${track_title}.mkv" \
	 --title "${track_title}" \
	 $chapters

echo mkvmerge -o "${track_title}.mkv" \
	 --title "${track_title}" \
	 --chapters "${track_title}/chapters.txt"

gives me this result:

mkvmerge -o a b.mkv --title a b --chapters "a b/chapters.txt"
mkvmerge -o a b.mkv --title a b --chapters a b/chapters.txt

do you see any mistake?

Offline

#5 2012-08-20 16:18:37

johannesg00
Member
Registered: 2010-11-30
Posts: 36

Re: Bash Script Problem

Without the \" i get this error:
"Fehler: Die Datei 'a' konnte nicht zum Lesen geöffnet werden"

Offline

#6 2012-08-20 16:24:44

sebcactus
Member
From: Germany
Registered: 2005-01-27
Posts: 277

Re: Bash Script Problem

What is your data structure?
Do you have two directories a and b or one called "a b"?
Are you sure the second line is working?

Offline

#7 2012-08-20 16:35:44

johannesg00
Member
Registered: 2010-11-30
Posts: 36

Re: Bash Script Problem

i have one directory called "a b", and the second line is working fine... i have no idea what is wrong..

Offline

#8 2012-08-20 16:39:42

sebcactus
Member
From: Germany
Registered: 2005-01-27
Posts: 277

Re: Bash Script Problem

I think here is a solution with explanation:
http://fvue.nl/wiki/Bash:_Why_use_eval_ … pansion%3F

/learned something smile

So I guess this should work:

#!/bin/bash

track_title="\"a b\""
chapters="--chapters ${track_title}/chapters.txt"

eval mkvmerge -o ${track_title}.mkv \
	 --title ${track_title} \
	 $chapters

Last edited by sebcactus (2012-08-20 16:55:28)

Offline

#9 2012-08-20 16:55:38

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,719

Re: Bash Script Problem

sebcactus wrote:

I think here is a solution with explanation:
http://fvue.nl/wiki/Bash:_Why_use_eval_ … pansion%3F

<snip>

Might want to check out this before going crazy with eval.


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#10 2012-08-20 17:10:35

sebcactus
Member
From: Germany
Registered: 2005-01-27
Posts: 277

Re: Bash Script Problem

It does not look crazy for the moment, but good to know smile

Offline

Board footer

Powered by FluxBB