LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-02-2007, 01:09 PM   #1
d1l2w3
Member
 
Registered: May 2004
Location: Amboy WA USA
Distribution: Mandriva 2007
Posts: 366

Rep: Reputation: 30
Need help with a script.


I am trying to backup DVD's that I own.

The following script works fine until the line:
dd if=/dv_dvd/* of=/dev/hdd
How do I solve this?

Also; once I type in the correct directory,
I get the error;
dd: opening `/dev/hdd': Read-only file system
How do I solve this?

Thanks,
dlw

echo
cd /hdb/Movies/
echo
echo "Enter Movie Title."
read -e path
mkdir $path
cd /hdb/Movies/$path
echo
echo
echo "Create one large *.vob."
vobcopy -l
echo
echo
echo "Remove DVD."
echo
echo "Insert Blank DVD."
echo
echo "Extracting video"
echo
tcextract -i *.vob -t vob -x mpeg2 > movie.m2v
echo
echo "Extracting audio"
echo
tcextract -i *.vob -a 0 -x ac3 -t vob > audio.ac3

vsize=`du -b movie.m2v | cut -c 1-10`
audioa=`du -b audio.ac3 | cut -c 1-9`

dvdlessaudio=$((4700000000-$audioa))
division=$(echo "scale=2; $vsize/$dvdlessaudio" | bc)
req=$(echo "scale=2; $division*1.05" | bc)
echo " "
echo "Requant factor for this movie is:" "$req"
echo
echo "Shrink video"
tcrequant -i movie.m2v -o shrinked.m2v -f $req
echo
echo "Multiplexing"
echo
mplex -f 8 -o final.mpg shrinked.m2v audio.ac3
echo
echo "Authoring"
echo
dvdauthor -t -o dv_dvd final.mpg
dvdauthor -o dv_dvd -T
echo
echo "Copy to DVD."
echo
dd if=/dv_dvd/* of=/dev/hdd
echo
echo "DVD is ready."
echo
# Requires; libdvdcss / transcode / mjpegtools / dvdauthor / cdrecord (mkisofs) /lsdvd /bc
 
Old 02-02-2007, 01:28 PM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
A couple of things.

First off /dev/hdd is the DEVICE for the hard drive. Unless this is an unformatted hard drive (unlikely) you don't want to be doing a dd to the DEVICE. You want to dd to a FILE on the filesystem mounted on the DEVICE. Type "fdisk -l /dev/hdd" to see what partitions you have on the device. Type "df -h" to see what filesystems you have mounted using those partitions.

Secondly Trying to dd in multiple files and output to a single file would not give you the images you want. What you want to do is a for loop to do a dd for EACH of the files.

Something like this instead of the dd command you currently have:

Code:
for DVD in `ls /dv_dvd`
do dd if=/dv_dvd/$DVD of=/filesystem/$DVD.img
done
 
Old 02-02-2007, 01:38 PM   #3
d1l2w3
Member
 
Registered: May 2004
Location: Amboy WA USA
Distribution: Mandriva 2007
Posts: 366

Original Poster
Rep: Reputation: 30
/dev/hdd is /mnt/cdrom
 
Old 02-02-2007, 01:39 PM   #4
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
So write to /mnt/cdrom rather than /dev/hdd. /mnt/cdrom being the filesystem.

However I don't know that you can just write to it like that. It seems you'd need to "burn" the CD which is a little more complicated than just copying things to it.

Last edited by MensaWater; 02-02-2007 at 01:42 PM.
 
Old 02-02-2007, 03:05 PM   #5
d1l2w3
Member
 
Registered: May 2004
Location: Amboy WA USA
Distribution: Mandriva 2007
Posts: 366

Original Poster
Rep: Reputation: 30
This is the way the script is now:

49 For DVD in 'ls /dv_dvd'
50 dd if=/dv_dvd/$DVD of=/mnt/cdrom/%DVD.img
51 done

This error appears;
line 50; syntax error near unexpected token 'dd'


This is where the script stops.
Everything in 'VIDEO_TS' works fine.
 
Old 02-02-2007, 03:09 PM   #6
d1l2w3
Member
 
Registered: May 2004
Location: Amboy WA USA
Distribution: Mandriva 2007
Posts: 366

Original Poster
Rep: Reputation: 30
I don't know if 'dd' will write to a dvd either.
I was told it was and saw it used elsewhere.
If it won't then I'll have to try something else.

Any ideas?
growisofs maybe
 
Old 02-15-2007, 09:37 PM   #7
anon107
LQ Newbie
 
Registered: Feb 2007
Posts: 5

Rep: Reputation: 0
Hi,
I think the following might help....?
In your script:
49 For DVD in 'ls /dv_dvd'

should be:

49 For DVD in `ls /dv_dvd`

the back tick is just under ~ on the keyboard
 
Old 02-16-2007, 03:33 PM   #8
d1l2w3
Member
 
Registered: May 2004
Location: Amboy WA USA
Distribution: Mandriva 2007
Posts: 366

Original Poster
Rep: Reputation: 30
Thanks for replying pitcat.

The following script works great except for writing to a DVD.
I use K3b for that.
It would be nice if it would copy to a DVD in one operation.
There are a couple of hundred do to.

Any ideas appreciated.
dlw

echo
cd /hdb/Movies/
echo
echo "Enter Movie Title."
read -e path
mkdir $path
cd /hdb/Movies/$path
echo
echo
echo "Create one large *.vob."
vobcopy -l
echo
open /dev/hdd/
echo
echo "Remove DVD."
echo
echo "Insert Blank DVD."
echo
echo "Extracting video to movie.m2v."
echo
tcextract -i *.vob -t vob -x mpeg2 > movie.m2v
echo
echo "Extracting audio to audio.ac3."
echo
tcextract -i *.vob -a 0 -x ac3 -t vob > audio.ac3
echo
echo "Clean up *.vob."
echo
rm *.vob
echo
vsize=`du -b movie.m2v | cut -c 1-10`
audioa=`du -b audio.ac3 | cut -c 1-9`

dvdlessaudio=$((4700000000-$audioa))
division=$(echo "scale=2; $vsize/$dvdlessaudio" | bc)
req=$(echo "scale=2; $division*1.05" | bc)
echo " "
echo "Requant factor for this movie is:" "$req"
echo
echo "Shrink video"
tcrequant -i movie.m2v -o shrinked.m2v -f $req
echo
echo
echo "Multiplexing"
echo
mplex -f 8 -o final.mpg shrinked.m2v audio.ac3
echo
echo "Clean up shrinked.m2v."
rm shrinked.m2v
echo
echo "Clean up movie.m2v."
rm movie.m2v
echo
echo "Clean up audio.ac3."
rm audio.ac3
echo
echo "Authoring"
echo
dvdauthor -t -o dv_dvd final.mpg
dvdauthor -o dv_dvd -T
echo
#echo "Clean up final.mpg."
# rm final.mpg
#echo
#echo "Copy to DVD."
#echo
# dd if=$DVD of=/mnt/cdrom/%DVD.img
# done
#echo
# eject /dev/hdd/
#echo "DVD is ready."
#echo
# Requires; libdvdcss / transcode / mjpegtools / dvdauthor / cdrecord (mkisofs) /lsdvd /bc
 
Old 03-20-2007, 11:34 AM   #9
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
maybe cdrecord will record the dvd from the command line.

its just files that need to be recorded.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Iptables (with masq) troubleshooting, very simple script attached script and logs. xinu Linux - Networking 13 11-01-2007 04:19 AM
Directory listing - Calling shell script from a CGI script seran Programming 6 08-11-2005 11:08 PM
How to start a Tcl/Tk script by simply invoking the script file itself ? cyu021 Programming 2 10-10-2004 11:00 AM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 12:20 AM
linux 9 and java script error - premature end of script header sibil Linux - Newbie 0 01-06-2004 04:21 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:56 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration