Bash script help
Hello!
I'm working on a simple bash script that ultimately will read the name of a cd/dvd and output that as a header into a document, then read the file contents and output them formatted into the file. My first problem is that I don't know how to get the disk name outputted without Volname (Read Next). My second problem is that I'm using Cygwin for Bash and unfortunately don't have Volname available. So, I was thinking possibly outputting some LS with a switch that might show the volume name and just GREP'ing it out, but I've had no luck finding any way to get a volume name outputted without Volname. Any help getting a disk's name outputted without Volname, or even a complete script of how someone else would do this if you had the time, would be great! Thanks! |
Well ... ls is iso9660 unaware. The volume name in iso9660 begins at
offset x8028, so a line like Code:
~ ]$ dd if=/dev/scd0 bs=2048 skip=16 count=1 2>/dev/null|cut -b 41-54 bytes long at best :})... you can play with the values if it fails. Cheers, Tink |
Works great, but if I were you I'd take /dev/cdrom, this way you use the link to the proper device and de device name itself can change.
Just a detail though. |
Heh ... true enough (not that I'm suggesting that the link
is always correct in all installations ;}). And another correction - the volume name can be 32 Bytes long, not 13. I looked at mkisofs' man-page ;} Code:
dd if=/dev/cdrom bs=2048 skip=16 count=1 2>/dev/null|cut -b 41-73 Cheers, Tink |
Thank you all for the help!
|
Welcome :}
... so is this version more workable for you than volname? Cheers, Tink |
Unfortunately, Cygwin has no /Dev, so this method doesn't work with it, but I did try that out and the idea works well in an actual fully functional Bash environment. I don't know if there is any way to get a volume name through this barring switching completely over to Linux on that computer or somehow importing the Volname command over to it.
|
I'd obviously be in favour of moving to Linux ;}
However, if you prefer to e operating in WinDOHs at this stage you could give qemu a shot, and emulate a PC running a real Linux under Windows. Or, of course, go the other way round and install some Linux, run qemu and have winDOHs tucked away in a virtual machine :} As for cygwin itself; I wouldn't have a clue whether it has the executable ready for install, or how trivial it would be to try and port that piece of software. Cheers, Tink |
Unfortunately, Cygwin has no /dev
Quote:
Of course I'd like to emphasise I'd rather see you use the versatile, robust, performant and generally way more efficient GNU/Linux over using the eternally blue-screeing, cut-n-perish, POS (Pitiful Operating System aka the MICROS~1 Game Platform) |
I do the same thing at work. I installed Cygwin on our video encoder, and have a simple two or three line script that reads the DVD backup's directory and produces a PDF catalog of the videos I've backed up. ( Although each line has a lot of pipes, using sed and enscript, so the line count of the script isn't totally an honest measure.)
I don't read the volume name, but instead enter the name of the disk as an argument to the script. Since I occasionally don't get the disc label right anyway, what I label on the top of the DVD with a marker is what I use as an argument to the script, and is what the catalog shows. |
All times are GMT -5. The time now is 07:18 AM. |