[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Festplatte auf Existenz testen


Hi,

On 05/03/2012 07:28 PM, Markus Hochholdinger wrote:
> dann ist doch alles super! :-)
> 
> Du kannst mit
>   test -e "/dev/disk/by-path/pci-0000:00:09.0-scsi-3:0:0:0"
> ueberpruefen ob die Festplatte angeschlossen ist!


Folgender Code ist sauberer:

test -b $(readlink -f /dev/disk/by-path/pci-0000:00:09.0-scsi-3:0:0:0)

Es wird nicht nur ueberprueft, ob da irgendwas rumliegt (koennte also auch
ein Symlink sein, der ins nichts zeigt, weil udev Bloedsinn gebaut hat),
sondern ob das Ziel des Symlinks ein Blockdevice ist.

Ausschnitt aus "man 1 test"

|       -b FILE
|              FILE exists and is block special
|[â?¦]
|       -e FILE
|              FILE exists

Gruesse
Moritz
-- 
UUGRN e.V. http://www.uugrn.org/
http://mailman.uugrn.org/mailman/listinfo/uugrn
Wiki: https://wiki.uugrn.org/UUGRN:Mailingliste
Archiv: http://lists.uugrn.org/