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.
I can get the disk name from isoinfo on my linux system, part of cdrtools, but it needs to read direct from the cd device:
Unless they specifically labelled and IDed all these disks though I suspect you're going to be disappointed. Most people don't bother and leave them as some generic name.
You're more likely to find what you want in looking at the contents of these CD's, the identification may be present somewhere in the data.
I am using OpenSUSE, latest version.
If I can do this without knowing the CD name, all the better. I just haven't figured it out yet. Somehow I need to seek the disk and find out the folder name without explicitly asking the user to "look" at the directory.
In addition, I have this sample script ALMOST running, but it blows up on the "mv" command, with an error that has me baffled. Also, since the station name is already part of the CD name, I might be able to parse that out and not force the user to enter it twice.
Well, look at /home/msugws/Documents/Sample_data/NMA2/NMA207N08. Is it a directory? If not, you can't copy things into it...
OpenSUSE should be able to install isoinfo one way or another, though I don't know what package name it hides inside for that distribution.
Quote:
Originally Posted by ws6transam
I am using OpenSUSE, latest version.
If I can do this without knowing the CD name, all the better. I just haven't figured it out yet. Somehow I need to seek the disk and find out the folder name without explicitly asking the user to "look" at the directory.
You don't have to ask the user to do something, just do it.
How to extract the data from your CD depends entirely on what the data in the CD looks like, though. I don't know for sure it's in there.
Maybe what I need is to rename the directory, not necessarily move it. However I thought mv was also the utlility for renaming stuff; i.e. files, and folders. I've used mv successfully at the command line to rename folders but when adding the $variables and doing it int eh shell script, it fails.
Ahh--- the $64,000 question. If you don't know what's on the CD, how do you copy it? That's what I need to find out. MY CD's are of varying formats: Sometimes there will be a top folder that is jammed with 4,000 little data files. Sometimes there is a subfolder called "Data" which contains the data files, along with a couple of extra supplemental folders with some small executable companions that I don't really care about. Other times, the discs will contain a single folder with the subfolders underneath it. SInce the format varies, I thought I could just identify the CD, specify the copy, and stream the whole thing into a single folder, then spend a few minutes deleting the extra folders if I find any, as I am inspecting the discs. The time consuming part is all the typing and copying and pasting necessary for getting the data onto the system. I just haven't figured out how to identify a mounted CD, other than to manually inspect with an ls command of /media. Unfortunately the CD isn't the only thing in that directory, and the CD name changes every time you mount a disc. It's a moving target.
---------- Post updated at 08:32 PM ---------- Previous update was at 04:43 PM ----------
I'm still at this ~
The problem I'm having is that whenever I load a CD into the drive, it mounts in the media directory with a completely new name, making it rather hard to pin down when running a script.
So, tonight I entered superuser, and created a directory called /media/cdrom as follows:
MRR2011 is the already-mounted CD with some miscellaneous documents.
Next, I issued a mount command as follows:
I then left superuser, and checked up on things:
Note that both /media/MRR2011 and /media/cdrom now reflect the same contents.
---
Though this *might* work, what I need to figure out is how to automount EVERY cdrom EVERY time, automatically so that I don't have to enter superuser and explicitly mount the disc each time. If I can get the disc to locate to the same location, I can write my script..
Of course, you are probably thinking that there's got to be a simpler, more elegant solution.... and so do I! So I'm still open to suggestions.
---------- Post updated at 09:06 PM ---------- Previous update was at 08:32 PM ----------
Okay --- Last bit of script for tonight. I found out that the double quotes were the problem in my ksh.
Now, whenever I mount the disc as superuser and manually mount it as /media/cdrom, the script will copy the files appropriately into a renamed folder at it's destination.
Now I just need to figure out how to get the disc to mount automatically each time, and I'll be nearly ready to cram these 1500 discs onto the system for phase 2 of the project.
--- ---------- Post updated at 10:14 PM ---------- Previous update was at 09:06 PM ----------
Last bit for tonight - I've been going on this for fourteen hours now.
I've had partial success with getting the mount to work, but I need to "touch" the CDROM with Dolphin before the automount process works.
However, by adding the following line to my /etc/fstab file, the cdrom loads as /media/cdrom . It doesn't work unless I poke the CDROM with Dolphin first, so it might not be the appropriate solution. However I'm at my wit's end on this one.
My contents of /etc/fstab where I simply added line 3.
--
--
Ahh--- the $64,000 question. If you don't know what's on the CD, how do you copy it? That's what I need to find out. MY CD's are of varying formats: Sometimes there will be a top folder that is jammed with 4,000 little data files. Sometimes there is a subfolder called "Data" which contains the data files, along with a couple of extra supplemental folders with some small executable companions that I don't really care about. Other times, the discs will contain a single folder with the subfolders underneath it. SInce the format varies, I thought I could just identify the CD, specify the copy, and stream the whole thing into a single folder, then spend a few minutes deleting the extra folders if I find any, as I am inspecting the discs. The time consuming part is all the typing and copying and pasting necessary for getting the data onto the system. I just haven't figured out how to identify a mounted CD, other than to manually inspect with an ls command of /media. Unfortunately the CD isn't the only thing in that directory, and the CD name changes every time you mount a disc. It's a moving target.
If the disks aren't consistent, then you can't depend on getting the name from the disk in any form. You might kludge something that'd work for a few but you'd still need to *check* every one of them, kind of defeating the point.
How about getting a big list of stations instead, and popping in the disks the program asks for?
Quote:
Though this *might* work, what I need to figure out is how to automount EVERY cdrom EVERY time, automatically so that I don't have to enter superuser and explicitly mount the disc each time. If I can get the disc to locate to the same location, I can write my script..
You had the right idea with the 'user' option in /etc/fstab. There's no reason it shouldn't work. what exactly does it not do, and what does poking it in dophin do?
I placed it inside the script after the first user prompt to give the drive time to spin up before the copy command is issued. This must be what was happening when I 'touched' the cdrom with Dolphin. It was mounting the drive. Now it's mounting without drama and going to town with the copy. I might add an explicit umount command at the very end of the script to tidy things up and ready it for the next CD.
Now, the contents are mounted at a consistent location, every time! In addition, the contents of the CDROM are written to the appropriate directory name with the assigned CD identification for easy retrieval.
...now, can I embed this script into it's own little icon on my window? Something that launches a terminal window, retrieves the CD number from the operator, then closes when finished? That'd be even 20% cooler. I'll work on that next, then get busy putting some discs into the system.
Phase 2 is to create a script that seeks each directory, identifies the data format, retrieves start & stop times from each file segment, then creates a database.
After that, (phase 3) it starts to get tricky as I begin to audit the timing, concantenate the files into larger, more manageable sizes, and then begin converting them from their various formats into a standard format.
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)