You can use /var/log/messages to check for the existence of an external drive through a series of grep commands. Here is my log output when I insert/remove a USB drive:
Jun 22 11:44:49 Christi kernel: umass0: <SanDisk Corporation Cruzer Mini, class 0/0, rev 2.00/0.10, addr 2> on uhub4 Jun 22 11:44:49 Christi root: Unknown USB device: vendor 0x0781 product 0x5150 b us uhub4 Jun 22 11:44:49 Christi kernel: da0 at umass-sim0 bus 0 target 0 lun 0 Jun 22 11:44:49 Christi kernel: da0: <SanDisk Cruzer Mini 0.1> Removable Direct Access SCSI-2 device Jun 22 11:44:49 Christi kernel: da0: 40.000MB/s transfers Jun 22 11:44:49 Christi kernel: da0: 122MB (250879 512 byte sectors: 64H 32S/T 1 22C) Jun 22 11:44:49 Christi kernel: GEOM_LABEL: Label for provider da0s1 is msdosfs/ . Jun 22 11:44:56 Christi kernel: umass0: at uhub4 port 2 (addr 2) disconnected Jun 22 11:44:56 Christi kernel: (da0:umass-sim0:0:0:0): lost device Jun 22 11:44:56 Christi kernel: (da0:umass-sim0:0:0:0): removing device entry Jun 22 11:44:56 Christi kernel: GEOM_LABEL: Label msdosfs/ removed. Jun 22 11:44:56 Christi kernel: umass0: detached I'm sure you can come up with creative ways to write a script that checks for when the disk is detached. "Bono Vince Malum" -- -Camilo > Date: Sat, 21 Jun 2008 21:44:09 +0000 > From: Helge Rohde <[EMAIL PROTECTED]> > Subject: shellscript conditional to check for external disk > To: email@example.com > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain; charset="us-ascii" > > Hello List, > > I need to write a backup script, and one of the required > actions would be a > copy of the backup to an external firewire drive. I would > like to make this > as easy as possible for the local staff, so i'd like to > check whether the > drive is attached, if necessary mount it, copy over the > backup and unmount > it again, so that the local staff can swap the external > disks when they're > not used. > > Is there a canonical way to achieve what i want? I played > with the idea of > simply checking for /dev/da0s1d's existance, but that > won't disappear on > disconnect, so that would leave the is a possibility that > although da0 is > in /dev, it might not be connected. > > Any ideas or RTFM-pointers? > > Helge _______________________________________________ firstname.lastname@example.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"