Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 11-04-2005, 09:47 AM   #1
Registered: Feb 2005
Distribution: Xubuntu 12.04 LTS
Posts: 154

Rep: Reputation: 16
error in script for copying scratched cds

I have a scratched data CD containing one .avi file. Using normal copying methods on Linux and Windows ended up with errors. I found a hopefully helpful script on

I copied the script to a text file: unscratch and copied it to /usr/local/bin.

[root@localhost cdrom]# chmod +x /usr/local/bin/uscratch
[root@localhost cdrom]# vim /usr/local/bin/uscratch
BYTES==`fdisk -l /dev/hdc | grep Disk | cut -f2 -d"," | cut -f2 -d" "`
BLOCKS=`dc -e "$BYTES 512 / p"`
echo $BLOCKS
while [ "$POS" -le "$BLOCKS" ] ; do
         let RETRY=1
         let RCOUNT=0
         while [ ! "$RETRY" -eq "0" ] ; do
         COPIED=`dd if=/dev/hdc of=/mnt/sdab/etc/tmp/test.iso seek=$POS skip=$POS count=$COUNT 2>&1 | grep "records out" | cut -f1 -d"+"`
         echo -n Copied $COPIED blocks from $POS " "
         let POS+=$COPIED
         if [ "$COPIED" -ne "$COUNT" ] ; then
                 echo Copied not equal to count!
                 if [ "$POS" -ne "$BLOCKS" ] ; then
                         echo And were not at end of disc
                         let RETRY=1
                 else echo Yahoo!!! End of disk!
                      exit 1
                 else let RETRY=0
         if [ "$COPIED" -eq "0" ] ; then
                 let POS-=10
         echo with Result $RETRY and $RCOUNT retries
         let RCOUNT++
         if [ "$RCOUNT" -ge "50" ] ; then
                 echo Ctrl-S here to clean disk
                 eject /dev/hdc
                 sleep 1
                 eject -t /dev/hdc
                 sleep 1
                 let RCOUNT=0
[root@localhost bin]# uscratch
Disk /dev/hdc doesn't contain a valid partition table
/usr/local/bin/uscratch: line 1: dc: command not found

/usr/local/bin/uscratch: line 7: [: : integer expression expected
I do not know how to correct these errors as i am a complete newbie to scripts. The CD was well mounted when i ran the script.
Old 11-05-2005, 03:18 AM   #2
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
the first error about the lack of partition table isn't an error. and as for the other, clearly you don't have dc installed.
Old 11-07-2005, 11:58 AM   #3
Registered: Feb 2005
Distribution: Xubuntu 12.04 LTS
Posts: 154

Original Poster
Rep: Reputation: 16
And how should i install dc? Searched on google, but did not find no source package to compile or anything.


Dc comes in with bc.

Last edited by landroni; 11-23-2005 at 08:53 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
copying audio cds skoot Linux - Newbie 8 05-18-2005 07:56 AM
Copying files from scratched CD Fade_t Linux - Software 1 05-01-2005 12:57 AM
Good ripper for scratched CDs? BaltikaTroika Linux - Software 1 11-01-2004 07:42 AM
copying cds lxandrthegr8 Linux - Hardware 0 08-13-2003 03:27 PM
Problem copying audio CDs Wynd Linux - General 2 05-05-2003 07:33 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:36 AM.

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