Hi, since $EMAILMESSAGE is a variable and not a file you can not use input redirection like that. Also it is typically good practice to quote variable references..
You could try:
or better yet:
Which would protect against awkward characters in the email message body.
Is $RECIPIENT set to a valid email address?
Last edited by Scrutinizer; 06-01-2010 at 09:37 AM..
This User Gave Thanks to Scrutinizer For This Post:
Hi, since $EMAILMESSAGE is a variable and not a file you can not use input redirection like that. Also it is typically good practice to quote variable references..
You could try:
or better yet:
Which would protect against awkward characters in the email message body.
Is $RECIPIENT set to a valid email address?
Hey Scrutinizer,
You seem to live up to your display id.I have made the changes accordingly. And yes the e-mail id is set to a valid id. I recieved the mail with all the the messages that contain error or warning.
I will put up the updated code separately.
Could you also give me a hint on how i could do the tasks of script. The main task is to scan the log file for new entries. I am not able to figure out how to scan the log file for the first time and then when the script is run the 2nd time, it needs to scan only new entries and ignore previous entries.
My approach was to create a tmp_log file of the log that is being scanned and then read from there. But i then realized if a different log file is scanned every time then my approach would fail. What is your opinion? Could you please give a logic and possible commands to use.
I might consider using wc for counting line numbers and then compare the logfile given asn argument with tmp_log that the script creates. then find the difference of the lines and print that in a second tmp_log file and do operations on that.
Again, Thanks for you valuable feebacks.
---------- Post updated at 11:08 PM ---------- Previous update was at 10:52 PM ----------
New improvements in the script are:
This script now searches for string mentioned searched using egrep.
Stores output of egrep in a variable and is passed to the email message variable.
It successfully sends an email with the entries of the specified log file that matched the string pattern in egrep
The code is below. I have tried to highlight all the recent updates that were made:
The output of the script now is as below:
Last edited by vin8465; 06-01-2010 at 10:13 AM..
Reason: Added output of script
Hi pseudocoder,
you are right. But my main intention of putting the echo there was to check what line in the script has been executed so far. Also I need to figure out how nt to send a mail if nothing is found from the searched string pattern.
I still am trying to figure out how the script can be modified to monitor and report only new entries when it is run for the second time with the same log file as an argument.
---------- Post updated at 08:44 AM ---------- Previous update was at 08:42 AM ----------
thanks for pointing that out. I will remember to take that out as it looks a bit misleading.
---------- Post updated at 01:36 PM ---------- Previous update was at 08:44 AM ----------
I have reformatted the code to suit the needs of the script task.
I have tried to highlight all the pieces of code that has been shifted, added or changed in blue.
All improvements required are highlighted in red. I have updated certain parts of the code and highlighted it using orange I get the following error if the search pattern doesnt match. At least that that is what the problem according to me. The output of an unsuccessful run is as below: The output of a successful run is as below:
I am not sure that the following code works as it should.
---------- Post updated at 01:55 PM ---------- Previous update was at 01:36 PM ----------
Found the problem with the if statement. Changes are in blue
The output now if the log file does not contain the string pattern is
---------- Post updated at 06:05 PM ---------- Previous update was at 01:55 PM ----------
The script now basically works fine.Certain advanced requirements of the script task that i have not implemented are:
If same script is renamed to logcheck then the reports the script generates should be displayed in the command line.
Error messages that are repeated are to be counted and only one instance of error message is to be reported followed by the comment "The above message appeared n times"
Note: Time stamp is being ignored when making the above improvements. i.e a log entry having identical time stamps will not be considered when grouping messages.
The code is as below. I have reformatted the entire code, so have not highlighted parts of the code.
The output of a successful run will be as below depending on the situation: Could someone please help me with the advanced parts. I need urgent help to finish this script off today itself.
Last edited by vin8465; 06-02-2010 at 09:25 PM..
Reason: Updated code to match code format
I am having trouble getting mail to work on a red hat server. At first I was getting this message.
Diagnostic-Code: X-Postfix; delivery temporarily suspended: connect to :25: Connection refused
Then added the port to my firewall. Then I temporarily turned off selinux. I then copied this file... (1 Reply)
I want to monitor the maillog file in real time and send a mail when a certain grep condition is met. Every time the grep condition is met a mail will be sent. I wish to ignore all grep conditions 30 mins after each mail and thereafter continue monitoring.
For example:
Condition is met, mail... (1 Reply)
Hello,
I wanted to search specific string in the acitve log file and send an email if the search string found in the log.
Log file is written by application all the time. So, script has to search if any new log entry has the specific string for example " sample exception" and send an email. (1 Reply)
Hi
I want to monitor a file even if the file rotate. When a text occurs I want to send a mail.
Something like this but it's not working correctly:
tail -F mylog.log | grep 'MatchMe' |
while read line
do
echo $(date +"%Y-%m-%d %H:%M:%S") MatchMe occurs | mail -s "MatchMe"... (1 Reply)
Hi All
Need help
Can any one share a basic script that is used for monitor sendmail service whether online, offline.etc in solaris
Thanks in advance
Zimmy (5 Replies)
This is my log file and this is live log.
Any abnormal error other than following
I need to generate the email.
Log path : /DER/app/admin/ABC/bdump/erg.log
Current log# 2 seq# 103046 mem# 0: /ora2/oradata/ABC/redo02a.log
Current log# 2 seq# 103046 mem# 1:... (7 Replies)
This is my log file and this is live log.
Any abnormal error other than following
I need to generate the email.
Log path : /DER/app/admin/ABC/bdump/erg.log
Current log# 2 seq# 103046 mem# 0: /ora2/oradata/ABC/redo02a.log
Current log# 2 seq# 103046 mem# 1:... (1 Reply)
i have sun machines having solaris 9 & 10 OS . Now i need to send mail from the machines to my outlook account . I have the ip adress of OUTLOOK mail server. Now what are the setting i need to do in solaris machines so that i can use mailx or sendmail.
actually i am trying to automate the high... (2 Replies)
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
I am stuck and worried. My assignment was due a day ago and I was too busy completing other assignments due during the same time. I worry that not completing this assignment... (1 Reply)