Following Script Display possible USB devices attached to the system : Tested on Ubantu 10.04 LTS
#!/bin/sh
#author sanjeewaF
for udi in $(/usr/bin/hal-find-by-capability --capability storage)
do
device=$(hal-get-property --udi $udi --key block.device)
vendor=$(hal-get-property --udi $udi --key storage.vendor)
model=$(hal-get-property --udi $udi --key storage.model)
if [ `hal-get-property --udi $udi --key linux.sysfs_path | grep -i usb | wc -l` -gt 0 ]
then
echo "Possible USB:"
parent_udi=$(hal-find-by-property --key block.storage_device --string $udi)
mount=$(hal-get-property --udi $parent_udi --key volume.mount_point)
label=$(hal-get-property --udi $parent_udi --key volume.label)
media_size=$(hal-get-property --udi $udi --key storage.removable.media_size)
size=$(( media_size/(1000*1000*1000) ))
printf "$vendor $model $device $mount $label "${size}GB" \n"
fi
done
No comments:
Post a Comment