From owner-freebsd-hardware Thu Nov 9 11:29:47 2000 Delivered-To: freebsd-hardware@freebsd.org Received: from panzer.kdm.org (panzer.kdm.org [216.160.178.169]) by hub.freebsd.org (Postfix) with ESMTP id 5758437B4C5; Thu, 9 Nov 2000 11:29:38 -0800 (PST) Received: (from ken@localhost) by panzer.kdm.org (8.9.3/8.9.1) id MAA32118; Thu, 9 Nov 2000 12:26:26 -0700 (MST) (envelope-from ken) Date: Thu, 9 Nov 2000 12:26:26 -0700 From: "Kenneth D. Merry" To: Graham Guttocks Cc: freebsd-hardware@FreeBSD.ORG, freebsd-scsi@FreeBSD.ORG Subject: Re: query CD-ROM status from within a program? Message-ID: <20001109122625.A32056@panzer.kdm.org> References: <20001109050905.87034.qmail@web10307.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2i In-Reply-To: <20001109050905.87034.qmail@web10307.mail.yahoo.com>; from graham_guttocks@yahoo.co.nz on Thu, Nov 09, 2000 at 06:09:05PM +1300 Sender: owner-freebsd-hardware@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org On Thu, Nov 09, 2000 at 18:09:05 +1300, Graham Guttocks wrote: > Greetings, > > I'm looking for a way to manipulate a CD-ROM drive from within a shell > script (ksh, perl, python, whatever). I need to be able to eject the > tray, and also query whether the tray contains a disc or is empty from > within the program. The first is easily accomplished with a utility like > "eject", but how about the latter? Is there an easy way to tell whether > a FreeBSD system's CD-ROM drive contains a disk or not? You can eject the CD with camcontrol: camcontrol eject cd0 Or with cdcontrol: cdcontrol -f /dev/cd0c eject You can determine whether the drive is ready with camcontrol: camcontrol tur cd0 -v -C 2 -E Or with cdcontrol: cdcontrol -f /dev/cd0c status It might be easier to use camcontrol in a script, since it will exit with a non-zero status if the drive isn't ready. Ken -- Kenneth Merry ken@kdm.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hardware" in the body of the message