cdcheck Command
Purpose
Asks cdromd daemon information about a device.
Syntax
Description
The cdcheck command sends an appropriate command to the cdromd daemon to get information on a media or a device depending on the flag used.
The cdcheck command returns a zero (True) exit value and prints a message on stdout if the specified condition is true. Otherwise, the cdcheck command returns a nonzero (False) exit value and prints an error message on stderr.
cd<x> is managed by cdromd.
cd<x> is not mounted.
No media present in cd<x>.
When using cdcheck in shell scripts, the -q flag can be added to the cdcheck command so that no messages are printed on stdout and stderr. The only exception is the cdcheck command with the -m flag, which always prints the mount point on stdout so that the shell script can get this mount point.
Flags
Item | Description |
---|---|
-a | Checks if a device is managed by cdromd. |
-e | Checks if a media has been ejected from a device. |
-h or -? | Displays the command usage message. |
-m | Checks if a media is mounted on a device. |
-q | Specifies silent mode: Doesn't print any information
or error message. Note: If -q is used with the -m flag,
the mount point will be printed to stdout.
|
-u | Checks if a media is not mounted on a device. |
DeviceName | Specifies the name of the device. |
Exit Status
This command returns the following exit values:
- 0
- answer = yes.
- >0
- answer = no or error.
Examples
- To ask cdromd if cd0 is managed enter:
cdcheck -a cd0
- To ask cdromd if a media is mounted on cd1 without
any printed error messages, enter:
cdcheck -m -q cd1
- To ask cdromd if a media is not mounted on cd1 enter:
cdcheck -u cd1
- To ask cdromd if a media is not present on cd0 enter:
cdcheck -e cd0
- Shell script example:
DEVICE=$1 if [ cdcheck -a -q "$DEVICE" ]; then AUTO_MOUNT="ON" else AUTO_MOUNT="OFF" fi # Other initializations # ... if [ "$AUTO_MOUNT" = "ON" ]; then MOUNT_POINT=`cdcheck -m -q $DEVICE` else MOUNT_POINT="/tmp/MyProg_$$" mount -rv cdrfs $DEVICE $MOUNT_POINT fi if [ $? -ne 0 ]; then echo "mount $DEVICE failed" exit 1 fi # Now extract data from $MOUNT_POINT... # ... # End of processing. Umount the media if [ "$AUTO_MOUNT" = "ON" ]; then cdeject -q $DEVICE else unmount $DEVICE fi if [ $? -ne 0 ]; then echo "unmount $DEVICE failed" exit 1 fi