Skip to content
August 2, 2012 / doganay

DEVICE ACCESS CONTROL SCRIPT

#!/usr/bin/ksh
#############################################
# dac.sh v1.1
# Written by Mustafa DOGANAY - 2012
#############################################
if [ $# -ne 1 ];then
echo "Usage: dac.sh <Device_List_File>"
exit 1
fi
FILE=$1
if [ ! -f $FILE ];then
echo "Device List File does not Exist"
exit 3
fi
for DEV in $(cat $FILE);do
ls $DEV 1>/dev/null 2>/dev/null
if [ $? -eq 2 ];then
echo "$DEV : Device does not exist." >> result_$(date +%Y%m%d)_$$
else
dd if=$FILE of=/dev/null bs=512 count=1 2>/dev/null
if [ $? -ne 0 ];then
echo "$DEV : Permission denied or device failure" >> result_$(date +%Y%m%d)_$$
else
echo "$DEV : Success" >> result_$(date +%Y%m%d)_$$
fi
fi
done
cat result_$(date +%Y%m%d)_$$
rm result_$(date +%Y%m%d)_$$
exit 0

content of dev1.txt
-------------------
/dev/arsivcx600/arsdatadbf100
/dev/arsivcx600/arsdatadbf101
/dev/arsivcx600/arsdatadbf102

Usage
-----
$ chmod 700 dac.sh
$ ./dac.sh dev1.txt

/dev/arsivcx600/arsdatadbf100 : Success
/dev/arsivcx600/arsdatadbf101 : Success
/dev/arsivcx600/arsdatadbf102 : Failure

You see, raw device-102 get failure. You can not either access it, or soft link is corrupted
or raw-data is corrupted.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: