Copy contents of whatever's loaded into the CD drive


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Copy contents of whatever's loaded into the CD drive
Prev   Next
# 1  
Old 11-08-2011
Copy contents of whatever's loaded into the CD drive

Hello everyone,

I have about 1500 compact discs of seismic data that I need to retrieve and place onto the hard drive so that I can index and process them.
The data was generated at 20 seismic stations and each disc has a been assigned unique name. The name is NOT necessarily what is on the disc itself. In fact, there is no conformity into what the station operator chose to call each disc when it was created. Some of the disc names contain Cyrillic (Russian) characters and white space. The new name format is a nine character system that contains the four letter station code, the two digit year, a letter N, and a two digit code representing disc sequence.

I would first like to create a KSH script that does these things:

Once mounted in the CD drive bay, identify the disc name and store within a variable. (This is what I have not figured out how to do.)

Poll the user for the station name.
Poll the user for the new disc name.

Copy the contents of the CD into the appropriate directory.
Change the permissions on the file.
Rename the newly copied folder with the contents to reflect the newly assigned disc name.

I've got this much, which is a very wordy script that doesn't quite work. I want to remove the requirement for the user to type in the disc mount ID, and instead use what is there. There's got to be a variable somewhere in the system, but hell if I can't find it.

Anyone got any suggestions? I'm combing through the manuals, doing google searches, searching this forum, but haven't yet found the answer. Scripting, if you haven't guessed it, is essentially new to me. My programming skills have been proven to be rusty enough to get red dust on the keyboard. The last time I did anything remotely like this was in 1985 on a DEC PDP11.

---
Dan's KSH script example:

Code:
USEAGE="usage: copyCD - Copies the seismic CDs into the collection"    #
print -n "Ensure that the CD is first loaded within the CD drive and is mounted."
print -n "Enter the CD name: (SSSSYYNDD) where SSSS = station name, YY = year, DD = Disc ID:  "
read diskid
print -n "Enter the loaded CD identification: \n"           # I want to automate this part!
read cdname
print -n "Your disc name is "$diskid"\n"
print -n "Enter the name of the Station. "
read stationid
if [[ ! -d ~/Documents/Sample_data/$stationid ]]
then 
    mkdir ~/Documents/Sample_data/$stationid
    print -n "~/Documents/Sample_data/"$stationid" created.\n"
else
    print -n "Station directory already exists.\n"
fi

print -n "Begin copy of contents of "$cdname" into directory ~/Documents
/Sample_data/"$stationid"/"$diskid"/\n"

cp -rn "/media/$cdname" "~/Documents/Sample_data/$stationid/"

chmod -R 775 "~/Documents/Sample_data/$stationid/$cdname"

mv ~/Documents/Sample_data/$stationid/$cdname ~/Documents/Sample_data/$stationid/$diskid


Moderator's Comments:
Mod Comment Video tutorial on how to use code tags in The UNIX and Linux Forums.

Last edited by Franklin52; 11-09-2011 at 03:38 AM.. Reason: Please use code tags, thank you
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unable to copy contents

I am trying to move content of a folder usingls /backup/db_backups/INCREMENTAL/|while read file ; do mv $file /backup_LOCAL/db_backups/INCREMENTAL/ done...but when I run this command using a bash script I'm getting this error ./test.sh mv: cannot stat... (6 Replies)
Discussion started by: rocking77
6 Replies

2. Shell Programming and Scripting

Copy contents of one file to another

I need to write a script (in bash) that copies the content of the first file in each folder of a directory to the second file in the same folder. I tried this and it didn't work - it just came back with errors and I'm not sure how to fix it. Help is very much appreciated! for mpdir in... (4 Replies)
Discussion started by: LeftoverStew
4 Replies

3. Shell Programming and Scripting

Need help to copy contents of a file

Hi, I am stuck up with a problem of copying the contents of a directory where one of the folder name is changed daily. Problem: I have the folder structure as: RefWorlds2/LINGCC4_X64/odsdev/odessy/UTI/621GA_build_xxx/.../.. In the above path the build number (xxx) will be changed... (3 Replies)
Discussion started by: SathaKarni
3 Replies

4. UNIX for Dummies Questions & Answers

Real time status of tape drive loaded for backup

Do we have a way in solaris to actuallyu check in real time the activity of a tape when it is loaded for backup? I know mt -f /dev/rmt/0n stat will provide the status. If it's busy, meaning it's currrently on backup mode or someone is using it (fuser -u /dev/rmt/0n) I wanted to check if the... (3 Replies)
Discussion started by: lhareigh890
3 Replies

5. Shell Programming and Scripting

copy the contents between two keywords to a new file.

Hi All, I want to edit my gate level netlists by searching for the content between two patterns eg: ff1 \test/a0 ( .CLK(\test/ClkInt0_acb_00x1 ),.D(\test/Rakicc ), .QB(\test/X ), .VDD(1'b1), .VSS(1'b0)); ff1 \test/a1 ( .CLK(\test/medis0_acb_00x1 ),.D(\test/hedwc ), .QB(\test/X ),... (6 Replies)
Discussion started by: naveen@
6 Replies

6. Windows & DOS: Issues & Discussions

List Contents of Drive by size

I am having difficulty listing the contents of a specific disk drive including hidden files and folders by size on disk. Its been a while since i have used dos and batch files in windows as am used to UNIX so was wondering if anybody could help me with this? Regards, Alan Jackson (1 Reply)
Discussion started by: pure_jax
1 Replies

7. Shell Programming and Scripting

copy contents of one column in another

Hi, I want to pick contents of a column in a file and copy the contents of this to other column. awk can be used for this, but the number of fields are higher so awk will not help. Any other way to do this. e.g following file has some contents a follows a,b,c,d,e,f,9,0 i need... (4 Replies)
Discussion started by: raman1605
4 Replies

8. UNIX for Dummies Questions & Answers

copy folder contents

I need to make a new dir in side the dir lab5 the new dir is called testLab5 without changing directories copy all files from your lab5 directory into your testLab5 directory then i have to without chaning directories and using exactly one command remove all files that start with the... (1 Reply)
Discussion started by: robsk8_99
1 Replies

9. UNIX for Dummies Questions & Answers

How to a see the contents of my CD drive

How to a see the contents of my CD drive in a Scoopen server station. In a windows based system you just go to mycomputer- and than double click the cd rom drive icon...simple....But i need to see the same but for a SCO open server....i want the same for a floppy drive tooo... By the way, i... (4 Replies)
Discussion started by: BAM
4 Replies

10. UNIX Desktop Questions & Answers

How to a see the contents of my CD drive

in a Scoopen server station. In a windows based system you just go to mycomputer- and than double click the cd rom drive icon...simple....But i need to see the same but for a SCO open server....i want the same for a floppy drive tooo... By the way, i tried (scoadmin ) command but couldnt go... (1 Reply)
Discussion started by: BAM
1 Replies
Login or Register to Ask a Question