cat : ignore I/O error


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers cat : ignore I/O error
# 1  
Old 04-10-2010
cat : ignore I/O error

Hello,

I have to backup some cds but I get an I/O error message when I hit a bad sector (using the command cat) and my question is : what can I do to force the system to ignore theses errors (or all kind of errors) and let the process keep going?

(sorry for any eventuals language errors, I am french)

Thanks.
# 2  
Old 04-10-2010
Use "dd" with the "noerror" and "sync" options instead of "cat".
# 3  
Old 04-10-2010
Thanks i will have a look at this.

If we consider to only use cat : is it possible to just modify the C code of the cat command in order to avoid the process to stop? Or is it something else that stop the process?

Last edited by Actraiser47; 04-10-2010 at 01:44 PM..
# 4  
Old 04-10-2010
Of course it's possible given the source code. However:
  • it'd be a ridiculous amount of work
  • it could break things you didn't expect -- imagine your modified cat reading a file that gets truncated, and going into an endless loop when it tries to "read past" the "bad block"
  • It might need to work differently than the way you imagine it -- it wouldn't merely need to "skip past" bad blocks, it'd have to write empty blocks to match the blocks it skipped or else your output would be smaller than your input. which'd mean knowing a block size. which would mean either reading that from the disk or getting from the commandline somehow. etc. etc. etc.
  • cat is really not meant for dealing with block devices, while dd really is designed for them
  • There's already a perfectly good command that does precisely what you want the exact way you want to do it. dd's easy once you know it, and available almost anywhere.
Code:
dd if=/path/to/input of=/path/to/output conv=noerror,sync


Last edited by Corona688; 04-10-2010 at 06:08 PM..
# 5  
Old 04-10-2010
Actually dd's cousin ddrescure may be more suitable for the job.

Last edited by binlib; 04-10-2010 at 09:55 PM..
# 6  
Old 04-11-2010
Quote:
Originally Posted by binlib
Actually dd's cousin ddrescure may be more suitable for the job.
  1. They both work fine
  2. They're not cousins
  3. He almost certainly has dd and doesn't have dd_rescue
# 7  
Old 04-11-2010
Thanks for your replies.

So I used dd (not ddrescue) with suggested options but the backup has not been done correctly. When I just open a movie or program, it just doesnt work and when I open a plain text file (even rtf), I get long lines of weird caracters.

Soooo it didnt work and I dont really know what to do now... anyway I will try again (it tooks 5 hours).

EDIT : What means "noerror" and "sync"?
EDIT2 : OOPS! I just looked at the history of the commands I used and I didnt used the option "sync", just "noerror". Well I am really gonna give another 'correct' try. Scuse me again... (anyway can someone tell me what for are these options?)

---------- Post updated at 04:19 PM ---------- Previous update was at 10:00 AM ----------

Hello again

Well, this time it worked... everything from the test disc has been retreived... thanks for your help!

Last edited by Actraiser47; 04-11-2010 at 05:10 AM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Getting Error in with cat command

Hi All , Below is the script which I have written - export LOGDIR=/home/rmsbatch/testdata # TEMPDIR : Path where all non zero files need to be moved after search. export TEMPDIR=/home/rmsbatch/testdata/TEMP # RESULTFILE : Path of the Final File export... (3 Replies)
Discussion started by: LoneRanger
3 Replies

2. Shell Programming and Scripting

How to ignore error in command in bash script?

Hello, i have bash script where im cycling some command for different lines in external file. example: while read domain;do nslookupout=$(nslookup -type=ns $domain) || true another commands done < filenamewithdomains i added: || true after the command in belief it will just skip... (6 Replies)
Discussion started by: postcd
6 Replies

3. Emergency UNIX and Linux Support

How to ignore Netout Error.?

Hi All , Am using unix KSH . I would like to clarify two doubts. Whenever am transfering the zero size file am getting the warning message netout. files will be transferred to target server or not? I have used the code as if then VAR="ftp.sh -c put ${FILE} ${FILE}... (2 Replies)
Discussion started by: Venkatesh1
2 Replies

4. Shell Programming and Scripting

Error : cat: 0652-050 Cannot open

After processing around 300 files , I am getting the below error.Please help me to resolve it cat: 0652-050 Cannot open /dir1/dir2/dir3/dir/abc.txt mv: 0653-401 Cannot rename /dir1/dir2/dir3/dir/abc.temp to /dir1/dir2/dir3/dir/abc.csv: . . . how to avoid it. because I am getting... (1 Reply)
Discussion started by: vsachan
1 Replies

5. Shell Programming and Scripting

cat command error

I use the "cat" command to cancaterate files into a new file. Sometimes the cat command failed because there were too many files in the directory for cancateration. I also tried to use the "ls" command to put the list of files into a text file and then cancaterate each file one by one by... (6 Replies)
Discussion started by: lena keung
6 Replies

6. Shell Programming and Scripting

Error output of cat to /dev/null

Hello, I'm trying to send the error output of a 'cat' operation to /dev/null like this: cat /dirA/dirB/temp*.log > /dirA/dirB/final.log 2>/dev/null This works perfectly in a terminal, but not when placed in a script. If there are no files matching temp*.log the script outputs an error... (7 Replies)
Discussion started by: Nils88
7 Replies

7. Shell Programming and Scripting

Ignore error and get ls file count

I am trying to figure out how to run the below variable assignment in a shell script so that it will snuff the "no such file or directory" and just pass the count value. That way I can do a valid compare in the next step. num=`ls /appsrv/tmp/PrjRefData_20090428-*_in.xml | wc -l` ls:... (3 Replies)
Discussion started by: lynchmob
3 Replies

8. Shell Programming and Scripting

cat in the command line doesn't match cat in the script

Hello, So I sorted my file as I was supposed to: sort -n -r -k 2 -k 1 file1 | uniq > file2 and when I wrote > cat file2 in the command line, I got what I was expecting, but in the script itself ... sort -n -r -k 2 -k 1 averages | uniq > temp cat file2 It wrote a whole... (21 Replies)
Discussion started by: shira
21 Replies

9. UNIX for Dummies Questions & Answers

Difference between cat , cat > , cat >> and touch !!!

Hi Can anybody tell the difference between Difference between cat , cat > , cat >> and touch command in UNIX? Thanks (6 Replies)
Discussion started by: skyineyes
6 Replies
Login or Register to Ask a Question