Sponsored Content
Top Forums Shell Programming and Scripting Grep multiple instances and send email. Post 302541278 by ironmonkey555 on Saturday 23rd of July 2011 12:47:40 PM
Old 07-23-2011
MySQL

hey
may be you can check with the logfile path... please specify the full path to logfile variable in the beginning and then run... i think it should run... Smilie

Quote:
Originally Posted by saisneha
Hi,

Thank you all your help.

At last my code works to some extent and could not read the txt file. Here is the error.

cat: cannot open /home/xxx/AppInstance_status.txt
Null message body; hope that's ok
___________________________
Here is the script I executed.

#!/bin/sh

logFile=~/AppInstance_status.txt

#store in a variable; easier to maintain

AppInstance=(xxx,aaa,ddd,ccc,xxx,cccfg)

for i in "${AppInstance[@]}" ;
do
AppInstance_status=`ps -ef | grep $i | grep -v grep`

if [ -z "$AppInstance_status" ] ;
then
echo "App Instance $i is not running . $(hostname) as on $(date)" >> $logFile
fi
done

cat $logFile | mail -s "Alert: AppInstance status check on Production " xxxx@xxxx.com

The AppInstance_status.txt file is under the home directory at the same location where I run the scripts.

example: /home/xxx/scripts/AppInstance_status.txt

but it is trying to read from /home/xxx/AppInstance_status.txt. Do I need to change any where the location of the file? What I want it to do is to look for that txt file and run all 40 instances from the file and give the results if any of the instance is down.

It is too complicated but I badly need help in this script.

Please help and again thanks in advance.

Sai

---------- Post updated at 11:42 AM ---------- Previous update was at 11:35 AM ----------

I got the txt file moved to one upper level and my code started working but have a question to rectify it.

I want the txt file to display only the instances that are under stop status and not all the instances. Right now, it displays whatever in the txt without executing the command.

Can anyone help please.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Unable to send eMail from a UNIX-Host ( using mailx ) to a Outlook-email-addres(Win)

Hi A) I am able to send eMail using mailx from a UNIX ( solaris 8 ) host to my Outlook-email-ID : FName.Surname@Citigroup.com ( This is NOT my actual -eMail-ID). But in Outlook the "From :" eMail address is displayed as " usr1@unix-host1.unregistered.email.citicorp.com " .i.e the words... (2 Replies)
Discussion started by: Vetrivela
2 Replies

2. Shell Programming and Scripting

Using mailx to send email to multiple users.

Hi, I am using the mailx command to send email to multple users. The command works fine when i am sending mail to a single user but when i insert multiple email ids inside the quote it does not work. All the email ids are coming from a property file.Please have a lookt at the property file and... (4 Replies)
Discussion started by: priyaksingh
4 Replies

3. UNIX for Dummies Questions & Answers

to send email to multiple users

hi, i'm pretty new to this unix. i've been asked to create a shell script which will pick up the email id from a text file(stored in same machine, same directory) searches for that id in another file in which a product name( a one line text) is mentioned against it. then it should send a mail... (0 Replies)
Discussion started by: vishwas.shenoy
0 Replies

4. Shell Programming and Scripting

Grep with multiple instances of same pattern

Hi, This is my text file I'm trying to Grep. Apple Location Greenland Rdsds dsds fdfd ddsads http Received Return Immediately Received End My Grep command: grep only--matching 'Location.*Received' e. Because the keyword Received appears twice, the Grep command will stop at the last... (0 Replies)
Discussion started by: spywarebox
0 Replies

5. Shell Programming and Scripting

Grep with multiple instances of same pattern

Hi, This is my text file I'm trying to Grep. Apple Location Greenland Rdsds dsds fdfd ddsads http Received Return Immediately Received End My Grep command: grep only--matching 'Location.*Received' Because the keyword Received appears twice, the Grep command will stop at the last... (3 Replies)
Discussion started by: spywarebox
3 Replies

6. Shell Programming and Scripting

Script to send email after comparing the folder permissions to a certain permission & send email

Hello , I am trying to write a unix shell script to compare folder permission to say drwxr-x-wx and then send an email to my id in case the folders don't have the drwxr-x-wx permissions set for them . I have been trying to come up with a script for few days now , pls help me:( (2 Replies)
Discussion started by: nairshar
2 Replies

7. Programming

Control multiple program instances - open multiple files problem

Hello. This shouldn't be an unusual problem, but I cannot find anything about it at google or at other search machine. So, I've made an application using C++ and QtCreator. I 've made a new mime type for application's project files. My system (ubuntu 10.10), when I right click a file and I... (3 Replies)
Discussion started by: hakermania
3 Replies

8. Shell Programming and Scripting

How to send email with multiple attachments ?

Hello , I am trying to send an email with two attachments . I have tried all previous suggestion in this forum but none worked. I could send one attachment in an email by uuencode $file "$file" | mailx -m -s "File" xxx@xx.com but unable to send multiple attachments . I have tried ... (8 Replies)
Discussion started by: RaviTej
8 Replies

9. Shell Programming and Scripting

How do I use grep to pull incremental data and send to multiple files?

Hi Everyone, Im currently using the below code to pull data from a large CSV file and put it into smaller files with just the data associated with the number that I "grep". grep 'M053' test.csv > test053.csv Is there a way that I can use grep to run through my file like the example below... (6 Replies)
Discussion started by: TheStruggle
6 Replies

10. Shell Programming and Scripting

Loop multiple directory, find a file and send email

Hello ALL, need a BASH script who find file and send email with attachment. I have 50 folders without sub directories in each generated files of different sizes but with a similar name Rp01.txt Rp02.txt Rp03.txt ...etc. Each directors bound by mail group, I need a script that goes as... (1 Reply)
Discussion started by: penchev
1 Replies
WWW::Freshmeat::Project(3pm)				User Contributed Perl Documentation			      WWW::Freshmeat::Project(3pm)

NAME
WWW::Freshmeat::Project - retrieve project information WWW::Freshmeat::Project methods The "WWW::Freshmeat::Project" object provides some of the fields from the freshmeat.net entry through the following methods url_project_page URL of project page on Freshmeat url_homepage deprecated projectname_full desc_short desc_full license trove_id Removed. projectname_short www_freshmeat Additionally, it provides the following "higher-level" methods: name description Return either "projectname_full" (respectively "desc_full") or "projectname_short" (respectively "desc_short") if the former is empty. version Returns the version of the latest release. url Removed. "url_homepage" returns a freshmeat.net URL that redirects to the actual project's home page. This url() method tries to follow the redirection and returns the actual homepage URL if it can be found, or the URL to the freshmeat.net entry for the project. branches Removed. List of branches for project. Returns hash in form of (branch id => branch name). popularity Removed. Freshmeat popularity data for project. Returns hash with keys record_hits, url_hits, subscribers url_list Removed. url_list1 Returns list of URLs for project. Each URL is a WWW::Freshmeat::Project::URL object. real_author Removed. Returns name of author (not maintainer). release_date Removed. Returns date of latest release. maintainers Removed. Returns list of names of maintainers. 1; perl v5.14.2 2012-03-05 WWW::Freshmeat::Project(3pm)
All times are GMT -4. The time now is 08:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy