Fedora Linux Support Community & Resources Center
  #1  
Old 22nd January 2010, 09:40 PM
atavus Offline
Registered User
 
Join Date: Jan 2010
Posts: 16
macossafari
Script to determine optical media format?

Hi everyone. I need help with some bash scripting that can identify whether a mounted optical disk is a CDDA, DVD, Blu-Disk, etc. I'm running Fedora 12 64bit. Thanks for the help.
  #2  
Old 4th February 2010, 07:23 PM
atavus Offline
Registered User
 
Join Date: Jan 2010
Posts: 16
macossafari
Solution

I wouldn't have thought it to be so hard to find this solution, but after weeks of research I have one, and for all those who also need this info, here it is:

Code:
#! /bin/bash
## This script looks for an Audio CD, DVD, data or blank optical disc and echos 
## a positive reply, it's up to you to do something useful with it.

device="${1:-/dev/sr0}" # Change the device path to match your optical drive
udi=$(hal-find-by-property --key block.device --string $device | \
    while read u ; do \
        [[ "$(hal-get-property --udi $u --key block.is_volume)" == "true" ]] && \
        [[ "$(hal-get-property --udi $u --key volume.is_disc)" == "true" ]] && \
        [[ "$(hal-get-property --udi $u --key volume.disc.is_blank)" == "false" ]] && \
        echo $u ; \
    done)

if [[ "$udi" != "" ]]; then
    if [[ "$(hal-get-property --udi $udi --key volume.disc.has_audio)" == "true" ]]; then
        echo "Audio CD detected"
    elif [[ "$(hal-get-property --udi $udi --key volume.disc.is_videodvd)" == "true" ]]; then
        echo "Video DVD detected"
    elif [[ "$(hal-get-property --udi $udi --key volume.disc.has_data)" == "true" ]]; then
        if [[ "$(hal-get-property --udi $udi --key volume.is_mounted)" == "false" ]]; then
            pmount $device
        fi
	 echo "Data disc detected"
    fi
fi
Closed Thread

Tags
blu-ray, blueray, dvd

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Real media format SMIL to video armandocl Using Fedora 0 29th December 2007 07:38 AM
how to determine PCI ID of ndiswrapper?? wahaha Servers & Networking 0 9th March 2007 08:46 PM
cdrom mount as /media/(cdvolumename) instead of /media/cdrecord FC5 knutjorgen Using Fedora 4 5th August 2006 04:45 AM
How to determine whether it is FC3 or FC2? Fedora_Linux EOL (End Of Life) Versions 12 8th June 2005 10:31 PM


Current GMT-time: 13:20 (Wednesday, 19-06-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat