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


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Shell script to check the /etc/default/kbd file on a list of SUN servers
# 1  
Old 08-11-2011
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..
# 2  
Old 08-11-2011
Code:
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
This User Gave Thanks to itkamaraj For This Post:
# 3  
Old 08-11-2011
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..
# 4  
Old 08-22-2011
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

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

And run it using
Code:
while read servername
do
     ssh usrername@servername /tmp/kbdcheck.sh 
done < servernames.txt

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell Script to check a file

I'm required to write a simple shell script that when it runs it writes the output which is a simple barcode to a tmp flat file which I can do the bit I'm struggling with... The next time it runs I need to check the tmp output file to see if that barcode is in the output file and if it is send... (5 Replies)
Discussion started by: worky
5 Replies

2. UNIX for Dummies Questions & Answers

Need shell script to check file

Hi Experts, I am not good in writing script. Just stared.I am looking for shell script to check following parameters. 1) Number of files on remote Linux SUSE server.- Any directory and sub directory. 2) I should define number of files in script. Files should be variable. 3) Age of... (2 Replies)
Discussion started by: ApmPerfMonitor
2 Replies

3. Shell Programming and Scripting

Script to check numerous ports / servers (Solaris native)

Hi I'd like to check that a bunch of firewall rules have been applied and, therefore, want to write a script that basically does the following: telnet serverA port1 telnet serverA port2 telnet serverB port1 telnet serverB port2 I would just compile the list in excel and run it as a... (2 Replies)
Discussion started by: jibberish
2 Replies

4. Shell Programming and Scripting

C shell scripting, check if link exists on remote servers

Hi, I'm new to C Shell programming. I'm trying to check if a sym link exists on remote server if not send email. I'm not having much luck. Can anyone help? Here is what I have written but it doesn't work. It tells me that my variable was not defined. Here is part of the script, the second... (0 Replies)
Discussion started by: CDi
0 Replies

5. Shell Programming and Scripting

help needed with shell script to append to the end of a specific line in a file on multiple servers

Hi Folks, I was given a task to append three IP's at the end of a specific (and unique) line within a file on multiple servers. I was not able to do that with the help of a script. All I could was: for i in server1 server2 server3 server4 do ssh $i done I know 'sed' could be used to... (5 Replies)
Discussion started by: momin
5 Replies

6. Shell Programming and Scripting

shell script to take input from a text file and perform check on each servers and copy files

HI all, I want to script where all the server names will be in a text file like server1 server2 server3 . and the script should take servernames from a text file and perform copy of files if the files are not present on those servers.after which it should take next servername till the end of... (0 Replies)
Discussion started by: joseph.dmello
0 Replies

7. Shell Programming and Scripting

Script to monitor sun servers temperature

Dears, need help on developing a script to monitor sun server temperature , I'm using the below command to check the servers one by one /usr/platform/`uname -i`/sbin/prtdiag -v Servers Models are : 2 x Sun SPARC Enterprise M9000 Server 4 x Sun Fire V490 2 x Sun Blade T6300 Server... (1 Reply)
Discussion started by: bejo4ever
1 Replies

8. Shell Programming and Scripting

Review Check list for Unix Shell Script

Hi, I need Unix Shell Script Review Check list in the format of word or excel. Can any one provide the review checklist for unix shell script. Pls. (1 Reply)
Discussion started by: praka
1 Replies

9. Shell Programming and Scripting

unix shell script which inserts some records into a file located in remote servers...

All, I need to write an unix shell script which inserts some records into a file located in remote servers. * Get the input from the user and insert according the first row. It should be in ascending order. 123451,XA,ABA 123452,XB,ABB 123453,XC,ABC 123455,XE,ABE 123456,XF,ABF 123458,XG,ABG... (2 Replies)
Discussion started by: techychap
2 Replies

10. UNIX for Advanced & Expert Users

Default ALOM username and password for the Sun servers

Hi, Anyone please tell me the default ALOM username and password for the sun server(Sun fire V210). Thanks muthu (1 Reply)
Discussion started by: muthulingaraja
1 Replies
Login or Register to Ask a Question