LinuxQuestions.org
Review your favorite Linux distribution.
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 05-04-2010, 01:31 PM   #1
bluesword1969
Member
 
Registered: Jan 2010
Location: East Coast, USA.
Distribution: Gentoo, Debian, OpenBSD.
Posts: 70

Rep: Reputation: 25
Bash or Perl example: copying data from a CD/DVD, to hard drive.


Seeking a decent Perl or Bash script or hack used to copy data from a CD/DVD to local or even remote hard drive/storage.

Thanks!
 
Old 05-04-2010, 01:39 PM   #2
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by bluesword1969 View Post
Seeking a decent Perl or Bash script or hack used to copy data from a CD/DVD to local or even remote hard drive/storage.

Thanks!
What other than 'cp' do you need ?
 
Old 05-04-2010, 01:41 PM   #3
PMP
Member
 
Registered: Apr 2009
Location: ~
Distribution: RHEL, Fedora
Posts: 381

Rep: Reputation: 58
From perl or shell

Mount the drive.
Copy the data.
unmount the drive
 
Old 05-04-2010, 02:04 PM   #4
bluesword1969
Member
 
Registered: Jan 2010
Location: East Coast, USA.
Distribution: Gentoo, Debian, OpenBSD.
Posts: 70

Original Poster
Rep: Reputation: 25
Examples, please! Let me elaborate. Let's say you're copying items from a CD/DVD, to be later imported to say, MySQL, or something of the sort.

What's a good script that would copy the data, from the CD/DVD, into a directory in a sort of format like this:

cp -v /<data from CD/DVD> <your initials>-<the date>-<the directory name>

A pretty format that could be later imported to MySQL, or something of that nature.

Just looking for ideas.

Thanks!
 
Old 05-04-2010, 02:20 PM   #5
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by bluesword1969 View Post
Examples, please! Let me elaborate. Let's say you're copying items from a CD/DVD, to be later imported to say, MySQL, or something of the sort.

What's a good script that would copy the data, from the CD/DVD, into a directory in a sort of format like this:

cp -v /<data from CD/DVD> <your initials>-<the date>-<the directory name>

A pretty format that could be later imported to MySQL, or something of that nature.

Just looking for ideas.

Thanks!
Before you ask for examples maybe you'll formulate technical requirements ?

For example, who is "you" in <your initials> ? Current user ID ? User ID of the file owner on CD/DVD ?

What is <the date> ? I.e. file modification date on CD/DVD ? Current date ? Date entered on command line ?

What is <the directory name> ? I.e. what directory are you talking about ? Where should its name come from ?

Why are you asking about CD/DVD ? How data on mounted CD/DVD is different from any other data on disk (except for being read-only) ?

...

Have you read 'man cp' ? Do you know how 'cp -r ...' works ?
 
Old 05-04-2010, 02:34 PM   #6
bluesword1969
Member
 
Registered: Jan 2010
Location: East Coast, USA.
Distribution: Gentoo, Debian, OpenBSD.
Posts: 70

Original Poster
Rep: Reputation: 25
Quote:
Originally Posted by Sergei Steshenko View Post
Before you ask for examples maybe you'll formulate technical requirements ?

For example, who is "you" in <your initials> ? Current user ID ? User ID of the file owner on CD/DVD ?

What is <the date> ? I.e. file modification date on CD/DVD ? Current date ? Date entered on command line ?

What is <the directory name> ? I.e. what directory are you talking about ? Where should its name come from ?

Why are you asking about CD/DVD ? How data on mounted CD/DVD is different from any other data on disk (except for being read-only) ?

...

Have you read 'man cp' ? Do you know how 'cp -r ...' works ?
- The "me", is my current user ID: bluesword1969
- The "date" would be the current date.
- The directory name would be derived from the directory on the CD/DVD. So for instance:

US_EN_Speaker_data_vol1

This is a typical directory name that I find on a lot of the data CD's and DVD's that I encounter.

- It's not the mounting of the CD's and DVD's I'm really worried about. I'm using GNOME, so any disc that I pop in gets auto-mounted. I just want to open a shell, and fire up a script that copies the data right from the disc.

- Yes, I know what cp (-r) does. :-)

Thanks!
 
Old 05-04-2010, 02:50 PM   #7
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by bluesword1969 View Post
- The "me", is my current user ID: bluesword1969
- The "date" would be the current date.
- The directory name would be derived from the directory on the CD/DVD. So for instance:

US_EN_Speaker_data_vol1

This is a typical directory name that I find on a lot of the data CD's and DVD's that I encounter.

- It's not the mounting of the CD's and DVD's I'm really worried about. I'm using GNOME, so any disc that I pop in gets auto-mounted. I just want to open a shell, and fire up a script that copies the data right from the disc.

- Yes, I know what cp (-r) does. :-)

Thanks!
Then in Perl there is getpw* functions (see 'perldoc perlfunc' for them) to get user ID. You might end up with
Code:
chomp(my $user = `whoami`);
though.

Read about 'File::Spec', 'File::Basename', 'File::Path', 'Cwd' Perl modules for efficient dealing with paths.

Regarding date - look for "Perl date time modules".
 
Old 05-04-2010, 02:55 PM   #8
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
And, of course,

Code:
perldoc -f opendir
perldoc -f readdir
perldoc -f closedir
perldoc -f stat
.
 
  


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
Error while copying data to other Hard disk fa_khan50 Linux - Newbie 6 03-24-2008 06:46 AM
Copying files from internal Hard drive to USB 2.0 Hard Drive is NOT Behaving tubatodd Ubuntu 4 02-19-2007 04:32 PM
which DVD player can play DVD from hard drive *and* support DVD Menu ? tho_x_tran Linux - Software 16 11-16-2006 02:00 PM
Needing help copying large hard drive to smaller drive sdubble Linux - Software 1 02-21-2006 12:06 PM
perl->large data structures->copying lackluster Programming 0 08-20-2003 10:27 AM

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

All times are GMT -5. The time now is 01:21 AM.

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