EmbLogic's Blog

Shell Script for Character_Device_Driver

#! /bin/bash
cheakout_l()
{
echo “Do you want to look the all file for further editing [y/n]”
read responce
if [ $responce='y' ]
then
for file in $(ls *.h,v *.c,v)
do
co -l $file
done
fi
make clean
exit 0
}
cheakin()
{
for file in $(ls *.h *.c)
do
ci $file
done
}
cheakout()
{
for file in $(ls *.h,v *.c,v)
do
co $file
done
}
insert()
{

insmod ./modules/My_Char_Driver.ko NOD=3
echo “Do you want to print the proc devices table [y/n] ”
read responce
if [ $responce = 'y' ]
then
cat /proc/devices
fi
echo “Do you want to print the dmesg [y/n] ”
read responce
if [ $responce = 'y' ]
then
dmesg #-c
fi
}
remove()
{
rmmod ./modules/My_Char_Driver.ko
echo “Do you want to print the proc devices table [y/n] ”
read responce
if [ $responce = 'y' ]
then
cat /proc/devices
fi
echo “Do you want to print the dmesg [y/n] ”
read responce
if [ $responce = 'y' ]
then
dmesg #-c
fi
}
runapps()
{
echo “Do you want to compile application [y/n] ”
then
if ( make -f Makeapps )
then
echo “Application make successfully”
./apps
else
remove
un_link
cheakout_l
fi
fi
}
major_n()
{
echo “Enter the major_no”
read major_no
}
node()
{
echo “Do you want to create node the node [y/n] ”
read responce
if [ $responce = 'y' ]
then
mknod NODE c $major_no 0
fi
}
un_link()
{
echo “Do you want to unlink the node [y/n] ”
read responce
if [ $responce = 'y' ]
then
unlink NODE
fi
}
#—————————-script start———————————————————————————————
echo “Do you want to cheakin and cheakout [a/b] ”
read responce
if [ $responce = 'a' ]
then
cheakin
cheakout
else
unlink NODE
cheakout_l
fi

echo “Do you want to compile the char_driver [y/n] ”
read responce
if [ $responce = 'y' ]
then
if ( make )
then
echo “make successfully”
echo “Do you want to insert the char_driver [y/n] ”
read responce
if [ $responce = 'y' ]
then
then
insert
major_n
node
runapps
else
cheakout_l
fi
echo “Do you want to remove the char_driver [y/n] ”
read responce
if [ $responce = 'y' ]
then
remove
un_link
else
cheakout_l
fi
else
echo “make failed”
fi
else
echo “Ok bye bye”
cheakout_l
fi

cheakout_l
150,9 Bot

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>