LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Use of quotation marks in bash (http://www.linuxquestions.org/questions/programming-9/use-of-quotation-marks-in-bash-647844/)

dunryc 06-08-2008 02:02 PM

Use of quotation marks in bash
 
Hi all Im tryig to write a bash script to automate somewhat the creation of dvd's from avi source files, I am attmepting to use dvdauthor from my script wich uses a xmlfile called dvd.xml. I intendt to create the dvd.xml file from with in the script

a coorect example of the dvd xml file is below :-

Quote:

<dvdauthor>
<vmgm />
<titleset>
<titles>
<pgc>
<vob file="your_video.mpg" chapters="0,0:10,0:20,0:30,0:40,0:50" />
</pgc>
</titles>
</titleset>
</dvdauthor>
here is the part of the script where i attempt to create the above dvd.xml file

Quote:

echo "<dvdauthor>" > dvd.xml
echo " <vmgm />" >> dvd.xml
echo " <titleset>" >> dvd.xml
echo " <titles>" >> dvd.xml
echo " <pgc>" >> dvd.xml
echo " <vob file="new.mpg" chapters="0,0:10,0:20,0:30,0:40,0:50" />" >> dvd.xml
echo " </pgc>" >> dvd.xml
echo " </titles>" >> dvd.xml
echo " </titleset>" >> dvd.xml
echo "</dvdauthor>" >> dvd.xml
unfortunatley it doesnt quite work out as i expected i get the resulting xml file

Quote:

<dvdauthor>
<vmgm />
<titleset>
<titles>
<pgc>
<vob file=new.mpg chapters=0,0:10,0:20,0:30,0:40,0:50 />
</pgc>
</titles>
</titleset>
</dvdauthor>
as you can see from the above output the quotation marks are missing form the vob line is there any way i can avoid this ?

thanks for looking

Tischbein 06-08-2008 02:15 PM

Either escape the doublequotes you want to keep, as here:

Code:

echo "<dvdauthor>" > dvd.xml
echo " <vmgm />" >> dvd.xml
echo " <titleset>" >> dvd.xml
echo " <titles>" >> dvd.xml
echo " <pgc>" >> dvd.xml
echo " <vob file=\"new.mpg\" chapters=\"0,0:10,0:20,0:30,0:40,0:50\" />" >> dvd.xml
echo " </pgc>" >> dvd.xml
echo " </titles>" >> dvd.xml
echo " </titleset>" >> dvd.xml
echo "</dvdauthor>" >> dvd.xml

Note the \"'s.

Or else use single quotes as here:

Code:

echo '<dvdauthor>' > dvd.xml
echo ' <vob file="new.mpg" chapters="0,0:10,0:20,0:30,0:40,0:50" />' >> dvd.xml
echo ' </pgc>' >> dvd.xml

Yet another option is to use a "here" document:

Code:

cat <<EOF >dvd.xml
<dvdauthor>
 <vmgm />
 <titleset>
 <titles>
 <pgc>
 <vob file="new.mpg" chapters="0,0:10,0:20,0:30,0:40,0:50" />
 </pgc>
 </titles>
 </titleset>
</dvdauthor>
EOF

Har det gy. Tischbein.

dunryc 06-08-2008 02:24 PM

Quote:

Originally Posted by Tischbein (Post 3178512)
Either escape the doublequotes you want to keep, as here:

Code:

echo "<dvdauthor>" > dvd.xml
echo " <vmgm />" >> dvd.xml
echo " <titleset>" >> dvd.xml
echo " <titles>" >> dvd.xml
echo " <pgc>" >> dvd.xml
echo " <vob file=\"new.mpg\" chapters=\"0,0:10,0:20,0:30,0:40,0:50\" />" >> dvd.xml
echo " </pgc>" >> dvd.xml
echo " </titles>" >> dvd.xml
echo " </titleset>" >> dvd.xml
echo "</dvdauthor>" >> dvd.xml

Note the \"'s.

Or else use single quotes as here:

Code:

echo '<dvdauthor>' > dvd.xml
echo ' <vob file="new.mpg" chapters="0,0:10,0:20,0:30,0:40,0:50" />' >> dvd.xml
echo ' </pgc>' >> dvd.xml

Yet another option is to use a "here" document:

Code:

cat <<EOF >dvd.xml
<dvdauthor>
 <vmgm />
 <titleset>
 <titles>
 <pgc>
 <vob file="new.mpg" chapters="0,0:10,0:20,0:30,0:40,0:50" />
 </pgc>
 </titles>
 </titleset>
</dvdauthor>
EOF

Har det gy. Tischbein.

THanks for that i used your last example it worked great


All times are GMT -5. The time now is 09:22 PM.