Sponsored Content
Top Forums UNIX for Advanced & Expert Users send mail script only if condition is met Post 302562402 by orafup on Thursday 6th of October 2011 07:29:36 PM
Old 10-06-2011
send mail script only if condition is met

only wc -l greater than 0 then send email to owner, otherwise do nothing.

ie.

result=powermt display dev=all|awk '{print $7}'|grep -i dead|wc -l

if [ $result -gt 0 ]
then
echo $result
else
:
fi
mailx -s "there is dead path (s)" "mymail@mydomain.com"

-----------

it is not working at all beacusse it send email no matter what condition . I just want wc -l greater than zeo only
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Send email to user when condition met

Hi all, I plan to write a shell script to inform users on their task when certain condition met. example: If a then email user on action a else email user on action b. I'm pretty new in scripting, appreciate any suggestions. Thanks. (4 Replies)
Discussion started by: *Jess*
4 Replies

2. Shell Programming and Scripting

How to break a loop if condition is met

I am having trouble figuring this code I want to grep a text from a file and if it match certain text it break out of the loop or it should continue searching for the text Here is what I have written but it isn't working while true f=`grep 'END OF STATUS REPORT' filename` do if ... (9 Replies)
Discussion started by: Issemael
9 Replies

3. Shell Programming and Scripting

do nothing if condition is not met but not exit

Hello all, I created the below script....and it seemed to be working fine. My problem is i want the script to ignore rest of the things if my condition is not met but do not exit.... #!/bin/ksh ########################### ########################### # Set name of the listener, this... (2 Replies)
Discussion started by: abdul.irfan2
2 Replies

4. UNIX for Advanced & Expert Users

While loop only if a condition is met

All, I wrote the following section of code (which logically in PHP would of worked): tmpPATH=${1} tmpTAG=${2} if then while read tmpTAG tmpPATH do fi echo $tmpTAG echo $tmpPATH if then done < ./config.cfg fi (4 Replies)
Discussion started by: Cranie
4 Replies

5. Shell Programming and Scripting

Shell script that check the argument passed to it and prints error if test condition is not met

I want to make a script that check for the argument passed to it and generates an error in case any character/string argument passed to it. I am using below code, but its not working. can anyone help. #!/bin/bash if ]; then echo 'An integer argument is passed to the script hence... (3 Replies)
Discussion started by: mukulverma2408
3 Replies

6. Shell Programming and Scripting

Awk. Abort script if condition was met.

I want to abort script if input variable matched first field in any line of a file. #!/bin/sh read INPUTVAR1 awk "{if(\$INPUTVAR1 == $1) x = 1} END {if(x==1) print \"I want to abort script here\"; else print \"OK\"}" /etc/some.conf I tried "exit" and system("exit") but no luck. (1 Reply)
Discussion started by: urello
1 Replies

7. Shell Programming and Scripting

Getting the records once condition met

Hi All, Seeking for your assistance to get the records once the $2 met the condition. Ex. file 1.txt 123455,10-Aug-2020 07:33:37 AM,2335235,1323534,12343 123232,11-Aug-2015 08:33:37 PM,4234324,1321432,34364 Output: 123455,10-Aug-2020 07:33:37 AM,2335235,1323534,12343 What i did... (5 Replies)
Discussion started by: znesotomayor
5 Replies

8. Shell Programming and Scripting

Need help on how to append on the filename when condition met.

Hi All, Seeking for your assistance on how to append the specific string when $3 condion met. ex. file1.txt ar0050046b16,5,888,0,0,0,0.00,0.00,0.00,0.00,25689.55 ar0050046b16,5,0,0,0,0,0.00,0.00,0.00,0.00,25689.55 ar0050046b16,5,0,0,0,0,0.00,0.00,0.00,0.00,25689.55 expected output:... (5 Replies)
Discussion started by: znesotomayor
5 Replies

9. Shell Programming and Scripting

Add another condition to bash for when not met

In the below I can not seem to add a line that will add Not low if the statement in bold is not true or meet. I guess when the first if statement is true/meet then print low, otherwise print Not low in $(NF + 1). I am not sure how to correctly add this. Thank you :). if(low <= $2 && $2 <=... (5 Replies)
Discussion started by: cmccabe
5 Replies

10. UNIX for Beginners Questions & Answers

Manipulate condition to send mail based on output text in file

Hi All, I have a working script as below. echo "Files loaded with $(cat /var/tmp/script.X1.out)" | mail -s "Files loaded with return code" mailid This script takes the output from script.X1.out file and appends the text "Files loaded with return code" and sends the email. Now what I want... (5 Replies)
Discussion started by: midhun3108
5 Replies
SQLITE_FETCH_ALL(3)													       SQLITE_FETCH_ALL(3)

sqlite_fetch_all - Fetches all rows from a result set as an array of arrays

SYNOPSIS
array sqlite_fetch_all (resource $result, [int $result_type = SQLITE_BOTH], [bool $decode_binary = true]) DESCRIPTION
Object oriented style (method): array SQLiteResult::fetchAll ([int $result_type = SQLITE_BOTH], [bool $decode_binary = true]) array SQLiteUnbuffered::fetchAll ([int $result_type = SQLITE_BOTH], [bool $decode_binary = true]) sqlite_fetch_all(3) returns an array of the entire result set from the $result resource. It is similar to calling sqlite_query(3) (or sqlite_unbuffered_query(3)) and then sqlite_fetch_array(3) for each row in the result set. PARAMETERS
o $result - The SQLite result resource. This parameter is not required when using the object-oriented method. o $result_type -The optional $result_type parameter accepts a constant and determines how the returned array will be indexed. Using SQLITE_ASSOC will return only associative indices (named fields) while SQLITE_NUM will return only numerical indices (ordinal field numbers). SQLITE_BOTH will return both associative and numerical indices. SQLITE_BOTH is the default for this function. o $decode_binary -When the $decode_binary parameter is set to TRUE (the default), PHP will decode the binary encoding it applied to the data if it was encoded using the sqlite_escape_string(3). You should normally leave this value at its default, unless you are interoperating with databases created by other sqlite capable applications. RETURN VALUES
Returns an array of the remaining rows in a result set. If called right after sqlite_query(3), it returns all rows. If called after sqlite_fetch_array(3), it returns the rest. If there are no rows in a result set, it returns an empty array. The column names returned by SQLITE_ASSOC and SQLITE_BOTH will be case-folded according to the value of the sqlite.assoc_case configuration option. EXAMPLES
Example #1 Procedural example <?php $dbhandle = sqlite_open('sqlitedb'); $query = sqlite_query($dbhandle, 'SELECT name, email FROM users LIMIT 25'); $result = sqlite_fetch_all($query, SQLITE_ASSOC); foreach ($result as $entry) { echo 'Name: ' . $entry['name'] . ' E-mail: ' . $entry['email']; } ?> Example #2 Object-oriented example <?php $dbhandle = new SQLiteDatabase('sqlitedb'); $query = $dbhandle->query('SELECT name, email FROM users LIMIT 25'); // buffered result set $query = $dbhandle->unbufferedQuery('SELECT name, email FROM users LIMIT 25'); // unbuffered result set $result = $query->fetchAll(SQLITE_ASSOC); foreach ($result as $entry) { echo 'Name: ' . $entry['name'] . ' E-mail: ' . $entry['email']; } ?> SEE ALSO
sqlite_fetch_array(3). PHP Documentation Group SQLITE_FETCH_ALL(3)
All times are GMT -4. The time now is 08:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy