Shell script to check the /etc/default/kbd file on a list of SUN servers

Hello,
I want to create a shell script that would check the file "/etc/default/kbd" for the entry KEYBOARD_ABORT=alternate on a list of SUN Solaris servers.

If this entry is not uncommented (without #) then I should get a message/error report for the host which does not have the setting enabled.

I am a newbie in scripting and hence would need your support to get this done.

Thanking in anticipation.

Regards..

while read servername
do
    ssh user@$servername 'grep "^EYBOARD_ABORT\=alternate" /etc/default/kbd || echo "Pattern not found in $servername"'
done < servernames.txt

servernames.txt file which contains the sun solaris server names line by line

1 Like

How can we tweak the below script to get the preferred result?

If the entry "KEYBOARD_ALTERNATE=alternate" is not uncommented, then I should get a failure.

======================================================
# Verify alternate break signal is enabled on SUN systems.
#
if [[ `uname -s` != 'SunOS' ]] ; then
addskip "This is not SunOS so skip to check"
exit
fi
if [[ `grep "^KEYBOARD_ABORT\=alternate" /etc/default/kbd` != '' ]] ; then
addfailure "break signal not enabled"
else
addsuccess "break signal enabled"
fi

Thanks..

The solution that itkamraj gave is better solution.
Still if you want, Copy your script to a file named say, kbdcheck.sh.
Change permission to 755.
Create a servername list file.
Copy script to all servers' /tmp directory using

while read servername
do
     scp kbdcheck.sh usrername@servername:/tmp
done < servernames.txt

And run it using

while read servername
do
     ssh usrername@servername /tmp/kbdcheck.sh 
done < servernames.txt

[/COLOR]