LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-19-2012, 06:03 AM   #1
Fishbowler
LQ Newbie
 
Registered: Sep 2012
Location: Nottingham, UK
Distribution: Linux Mint
Posts: 7

Rep: Reputation: Disabled
Determining exit codes for unrar (or alternative) in Bash


The background:

I'm clearing down an external drive for my mother-in-law which contains lots of downloaded cruft, including rars and their contents. I've used fslint to clear out temp files and times where the rar has been extracted multiple times (and in one case, 27 times!!) but I can't see an easy way to trap when a download has been extracted zero times.

The best solution I can think of is to extract all of the rar files, fslint the drive again then bin off the rars entirely.

The problem:

What do I do with rar files that won't extract? I found this handy little script to test and rename them, but I'm having trouble discerning the difference between rar files that are actually corrupt and rar files that are passworded. To get the script to work, unrar needs to be passed the "-p-" flag, else it'll prompt for a password for every locked rar it finds (and this drive will have hundreds). I've confirmed that passing -p- to unrar for a passworded file always results in result code 3 (CRC Error).

Any ideas on what I can do, or perhaps on a command line tool that can actually tell the difference?
 
Old 09-19-2012, 06:51 AM   #2
414N
Member
 
Registered: Sep 2011
Location: Italy
Distribution: Slackware
Posts: 641

Rep: Reputation: 186Reputation: 186
Maybe expect could help you, but I think it's an overkill.
You just need a way to tell the difference between a password-protected rar and a corrupted one, am I correct?
Did you try with other software which support rar archives, like p7zip?
 
Old 09-19-2012, 07:25 AM   #3
Fishbowler
LQ Newbie
 
Registered: Sep 2012
Location: Nottingham, UK
Distribution: Linux Mint
Posts: 7

Original Poster
Rep: Reputation: Disabled
I did try p7zip, but the Diagnostics section of the man page shows nothing more concrete in error codes.
 
Old 09-19-2012, 07:41 AM   #4
414N
Member
 
Registered: Sep 2011
Location: Italy
Distribution: Slackware
Posts: 641

Rep: Reputation: 186Reputation: 186
I guess then that expect should help you in this matter.
To recognize password protected rar files you should match a "Password:" line (IIRC) in unrar's output.
 
1 members found this post helpful.
Old 09-19-2012, 08:32 AM   #5
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 15,656

Rep: Reputation: 5132Reputation: 5132Reputation: 5132Reputation: 5132Reputation: 5132Reputation: 5132Reputation: 5132Reputation: 5132Reputation: 5132Reputation: 5132Reputation: 5132
I would rather delete all those files - in case they can be downloaded again
 
1 members found this post helpful.
Old 09-19-2012, 08:54 AM   #6
Fishbowler
LQ Newbie
 
Registered: Sep 2012
Location: Nottingham, UK
Distribution: Linux Mint
Posts: 7

Original Poster
Rep: Reputation: Disabled
Expect looks like it might do what I want, but I think the expense of the effort might outweigh the gain. That said, I'm adding it to the list of things I need to learn. I worked around grep and sed for years, and now I've no idea how I lived without them! I'm going to use the script I linked to in the OP to rename all of the passworded files and move them away and leave them for the mum-in-law to deal with. I'm pretty sure that just with the non-passworded archives, I'll shave gigs and gigs from her drive.

Note to those in a similar boat who might later come across this: Copy the files to local storage first. Forgetting rar, even find is noticeably slower over USB!

Thanks to all for the help
 
  


Reply


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
[SOLVED] Bash Shell Script Exit Codes metallica1973 Programming 4 01-25-2012 12:14 PM
Zenity and exit codes Abezz Programming 2 02-03-2011 08:10 PM
exit codes history guttersnipe Programming 1 07-07-2008 08:35 PM
Bash scripting problem with exit codes Jeiku Programming 2 05-15-2006 02:22 AM
exit codes introuble Programming 2 05-08-2005 01:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:19 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