Help needed to write a shell script!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help needed to write a shell script!
# 1  
Old 10-10-2005
Help needed to write a shell script!

Hi,
I need to login to multiple servers(around 20) every day and get error messages from log file.The command i use to get this done is "$more /var/log/messages |grep error" and copy error messages.

I want this to be automated using a shell script and mail error messages to a given email id.

Can some one help me in creating a shell script?


Thanks in advance!

Cheers!
Sreedhar
# 2  
Old 10-10-2005
You will have to setup rsh or ssh connectivity between the central server where you will be collecting the files. By connectivity, I mean that one user from your central server should be able to connect to the other servers without using a password.

Then you can use this:
Code:
for server in a b c d; do
   ssh some_user\@$server grep error /var/log/messages > $server.log.$(date +%Y%m%d)
done

The grep command will run on the remote server, while the log file should get created on your central system. You could run this from cron.
# 3  
Old 10-11-2005
Java

Thanks a lot for the reply.

SSH is already enabled..most of the cases username is the same for all the servers but the password differs.I cant make anychanges to the servers coz I am not the administrator of the server and we dont own them. Is there a way where i can store server IPs , username and Passwords and send them non-interactively?

Regards,
Sreedhar
# 4  
Old 10-11-2005
You really should have key based authentication setup between the central server and the rest of the servers. You can use the fd filesystem to redirect input to ssh in Solaris, but it is not a portable method (has no parallel in HP-UX for instance).

Get in touch with the administrators and ask them to help you set this up.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Please help me to write the shell script

Please help me to write the shell script AC|NAME|STATE|MAXVALUE|MINVALUE---------heading 111|UMA|ODISHA|123,00.00|54.00 111|UMA|ODISHA|124,00.00|25.00 111|UMA|ODISHA|114,00.00|58.00 111|UMA|ODISHA|104,00.00|00.00 111|UMA|ODISHA|194,00.00|19.00 111|UMA|ODISHA|184,00.00|64.00... (5 Replies)
Discussion started by: alokjyotibal
5 Replies

2. Shell Programming and Scripting

How to write config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

3. UNIX for Dummies Questions & Answers

How to write Config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

4. Shell Programming and Scripting

Need to write a shell script

Hi, I need some help to write a script i need to write script that will count the no of logs generated for the day and specify the logfiles names which is not generated for the day. Default no of log generate per day is 29 if less than 29 logs generated it should specify the perticular logfile... (7 Replies)
Discussion started by: mail.chiranjit
7 Replies

5. Shell Programming and Scripting

Urgent help needed to write a script

User have given me about 450 commands, i just wanted to know the full path for those commands and the output should be redirected to a separate file. Instead of running "which" command each time to find the path for all those commands, i need to do this in a simple way by a script. which... (3 Replies)
Discussion started by: pgmax
3 Replies

6. Shell Programming and Scripting

Need to Write Shell Script based off of this shell command

I'm trying to read a bunch of log files and output the lines that contain particular strings. To accomplish this, I've been running the following from the command line: find . -name "*" | xargs grep " " | grep " " > output.txt Two grep statements are needed in case I'm looking for a... (3 Replies)
Discussion started by: Rally_Point
3 Replies

7. Shell Programming and Scripting

I need to write a shell script.

Hi Guys, I need to write a shell script, to which I have getting results from CPU and Memory Utilization. This is to generate automatically through Shell script by running cron job. Is it possible to write it. I am new to this shell scripting. Can you please help me on this ASAP. ... (6 Replies)
Discussion started by: lakshmanrk
6 Replies

8. Shell Programming and Scripting

please Write a shell script

Hi Team, I am unable to write script. please guide me. My rquirement is as given below one file will have three columns with n number of rows like hostname port sid -------- ---- --- sun056 1527 PSP1 sun111 1529 PRP1 sun107 1580 PRD1 the script should... (6 Replies)
Discussion started by: rvrao77
6 Replies

9. Shell Programming and Scripting

help needed to write script

I have to do a directory clean up on several machines. The task is as follows: 1. create a directory ' SCRIPTCLEANUP ' ( i KNOW IT) 2. list the directory 3. if directory and start with 'DQA' leave it, 4. if directory or file move it to the newly crated directory ( blanck directory delete)... (1 Reply)
Discussion started by: ajaya
1 Replies

10. Shell Programming and Scripting

need help to write shell script

. I wrote shell script with help to extract data and generate report . I need help to modify that in sub section . Currently I am generating the report in this format Version Name Host Total Number of Fails 10 Animator 45 10 Krachel ... (0 Replies)
Discussion started by: getdpg
0 Replies
Login or Register to Ask a Question