-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Monday 21 October 2002 05:04 pm, Thom Paine wrote:
> Is there a command or way to ready the volume id of a cd in the drive?
>
> I'm building some autoupdate scripts on rw discs and I'd like to
> implement in the script a little check to see that the right volume is
> in the drive.

I'm sure there are better ways, but none I can think of at present. This 
works on a mounted or unmounted cd in /dev/cdrom

$ strings /dev/cdrom | head -2
CD001
LINUX                           Red Hat Linux/i386 8.0

Since you would know the volume name you are looking for, you should be 
able to pass the output to grep. Something like this should work:

#! /bin/bash
strings /dev/cdrom | head -2 | grep -q "Red Hat Linux/i386" || { 
   echo "Error, Volume ID doesn't match!" 
   echo "Exiting"
   exit 1
  }

- -- 
- -Michael

pgp key:  http://www.tuxfan.homeip.net:8080/gpgkey.txt
Red Hat Linux 7.{2,3} in 8M of RAM: http://www.rule-project.org/
- --
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE9tKUin/07WoAb/SsRAi+LAKCB1puPabE75Rl0D8XUiBMSOlXyPQCgjFMx
fURpjBm2KPlMhFbOVILaBDQ=
=Lzlk
-----END PGP SIGNATURE-----




Reply via email to