LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-10-2006, 12:20 AM   #1
OnoTadaki
LQ Newbie
 
Registered: Mar 2004
Posts: 11

Rep: Reputation: 0
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!
 
Old 06-10-2006, 02:29 AM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
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
KNOPPIX
should do the trick (don't ask me why I think that the volume is 13
bytes long at best :})... you can play with the values if it fails.


Cheers,
Tink
 
Old 06-10-2006, 02:42 AM   #3
elluva
Member
 
Registered: Aug 2003
Location: Belguim, Ostend and Ghent
Distribution: Ubuntu
Posts: 600

Rep: Reputation: 30
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.
 
Old 06-10-2006, 02:44 AM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
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

Last edited by Tinkster; 06-10-2006 at 02:46 AM.
 
Old 06-10-2006, 02:46 PM   #5
OnoTadaki
LQ Newbie
 
Registered: Mar 2004
Posts: 11

Original Poster
Rep: Reputation: 0
Thank you all for the help!
 
Old 06-10-2006, 03:13 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Welcome :}

... so is this version more workable for you than volname?



Cheers,
Tink
 
Old 06-10-2006, 03:17 PM   #7
OnoTadaki
LQ Newbie
 
Registered: Mar 2004
Posts: 11

Original Poster
Rep: Reputation: 0
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.
 
Old 06-10-2006, 03:32 PM   #8
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
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
 
Old 06-10-2006, 07:59 PM   #9
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Unfortunately, Cygwin has no /dev
Quote:
"Beginning with Cygwin 1.3.4, raw devices are accessible by Cygwin processes using fixed POSIX device names. These fixed POSIX device names are generated using a direct conversion from the POSIX namespace to the internal NT namespace. E.g. the first harddisk is the NT internal device \device\harddisk0\partition0 or the first partition on the third harddisk is \device\harddisk2\partition1. The first floppy in the system is \device\floppy0, the first CD-ROM is \device\cdrom0 and the first tape drive is \device\tape0"
So that would be \device\cdrom0 IIGC...

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)

Last edited by unSpawn; 06-10-2006 at 08:05 PM. Reason: //--add-emphasis
 
Old 06-10-2006, 08:13 PM   #10
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
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.
 
  


Reply

Tags
solution



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
building a bash script from an install script paranoid times Programming 6 07-29-2006 03:24 AM
Bash script - executing a script through subdirectories bubkus_jones Programming 5 04-24-2006 05:05 PM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 12:20 AM
bash script - incrementing a filename in a script tslinux Programming 10 08-05-2003 11:58 PM
bash script prob: how can i tell the script that a 'dd' has finished? Frustin Linux - General 2 04-02-2003 05:34 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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