LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   DVD Backup Script (https://www.linuxquestions.org/questions/programming-9/dvd-backup-script-871015/)

seashell11 03-25-2011 03:46 PM

DVD Backup Script
 
I have an extensive DVD collection, and I want them backed up in case of a fire or other problem. I am trying to create a script to automatically prompts me for the name of the DVD and then backs the dvd up when I insert it. Following is what I have so far:

Code:

#!/bin/bash
name=0
read name
dvdbackup -M -n $name -o /home/seashell/Videos/Editing/DVDrip &
pid=$!
trap "
[ -e /proc/$pid ] && kill $pid
eject /dev/dvd
" EXIT

while [ -e /proc/$pid ]; do
sleep 0.25
echo -n .
done | zenity --progress --auto-kill

I am running kubuntu 10.10. When I run this in a terminal, nothing happens. Do you have any idea what I did wrong here?

corp769 03-25-2011 03:59 PM

Have you tried running the dvdbackup code to test the command by itself?

seashell11 03-25-2011 04:01 PM

The problem is my read command. If I take that out, and type in name=DarkKnight and then run the script it backs up Dark Knight correctly.

seashell11 03-25-2011 04:03 PM

In other words, if I change the script to this it runs correctly:

Code:

#!/bin/bash
name=DarkKnight
dvdbackup -M -n $name -o /home/seashell/Videos/Editing/DVDrip &
pid=$!
trap "
[ -e /proc/$pid ] && kill $pid
eject /dev/dvd
" EXIT

while [ -e /proc/$pid ]; do
sleep 0.25
echo -n .
done | zenity --progress --auto-kill


corp769 03-25-2011 04:07 PM

Try this:
Code:

#!/bin/bash
read -p "Enter backup name: " bname
dvdbackup -M -n $bname -o /home/seashell/Videos/Editing/DVDrip &
pid=$!
trap "
[ -e /proc/$pid ] && kill $pid
eject /dev/dvd
" EXIT

while [ -e /proc/$pid ]; do
sleep 0.25
echo -n .
done | zenity --progress --auto-kill


seashell11 03-25-2011 04:30 PM

You fixed! Thanks!

corp769 03-25-2011 04:33 PM

No problem man!

Cheers,

Josh


All times are GMT -5. The time now is 04:29 PM.