I have no idea what your usep and usep1 arrays are supposed to contain, but it is obvious that the code you have shown us can't possibly produce the output you say you are getting. Both of those arrays need to contain numeric values for your code to work and there is nothing in your code that prints the filesystem names if both of those arrays contain numeric values???
It would seem that you want to
take the mail command out of the loop,
initialize alertlist to an empty string before you start your loop,
use echo "$tmp" inside the loop,
add the contents of the variable tmp as an additional line in the variable alertlist inside the loop, and
after falling off the end of the loop, send mail if and only if ${#alertlist} is non-zero.
Please show us the code where you tried what I suggested in post #2 in this thread. Steps 1, 2, 4, and 5 of what I suggested do not appear in the code you showed us in post #3.
The code that you did show us in post #3 defines a function named alertlist whose body depends on what shell you're using (probably either the nested for loop in your code, a syntax error, or a comment) and which is never invoked in your script.
What operating system and shell are you using?
Do you really have a directory named $ in the directory in which you run this script? Using a name like that is certainly possible, but using it can frequently be accident prone. (Or does $/ have some special meaning in the shell you're using?)
sorry for late response I was out of my location, Here I've attached code as you suggested and updated,
1.) Please show us the code where you tried what I suggested in post #2 in this thread. Steps 1, 2, 4, and 5 of what I suggested do not appear in the code you showed us in post #3.
a.) use echo "$tmp" inside the loop! the result is
b.) The code that you did show us in post #3 defines a function named alertlist whose body depends on what shell you're using!
bash_version 4.1.2(1)-release
and finally the output of above script is
all it shows in a single line, but echo of "$tmp" variable is stored clear. But I need mail which contains information as it's stored in "$tmp" with proper alignment, Because now 2 of the mount points only passed our condition if it was more than 10 it's very complex to understand.
2.)What operating system and shell are you using?
RHEL 6.8
bash_version 4.1.2(1)-release
3.)Do you really have a directory named $ in the directory in which you run this script?
it refers the directory where the files are located, it's actually $HOME/monitor/ $HOME is home directory of username in my case username is vijay,
So
4.)Or does $/ have some special meaning in the shell you're using?
No, it redirect to the directory called $HOME/monitor. in post #1 I conclude that information.
Hope this will help.
[mod]Please use CODE tags as required by forum rules!
Last edited by Don Cragun; 05-15-2017 at 08:34 PM..
Reason: Add CODE and ICODE tags.
Try changing your script to:
and tell us what happens.
Note, however, that if a mounted filesystem is ever unmounted or a new filesystem is mounted between runs of your script, there is no guarantee that the order of the percentage values stored in the arrays usep and usep1 are in the same order. And note that if $HOME/monitor/log/disk_alert.log is not the name of an existing file whose size is larger than 0, the assignment to the partitions array will fail since you're reading the file diskcheck. instead of diskcheck.log:
and all of your assignments like this are wasting CPU and memory by using cat when it is not needed. Try:
instead.
a.)all of your assignments like this are wasting CPU and memory by using cat when it is not needed. Try:
Yes
While I run the script it seems everything okay as usual the output of run script is,
When I receive the mail it's remains with the old format
1.)
Note, however, that if a mounted filesystem is ever unmounted or a new filesystem is mounted between runs of your script, there is no guarantee that the order of the percentage values stored in the arrays usep and usep1 are in the same order!
I have the following script, and I want to assign the output ($10 and $5) from awk to N and L:
grdinfo data.grd | awk '{print $10,$5}'| read N L
output from gridinfo data.grd is: data.grd 50 100 41 82 -2796 6944 0.016 0.016 3001 2461. where N and L is suppose to be 3001 and 100. I use... (8 Replies)
Hi Guys,
I am very new to shell script and I need your help here to write a script. Actually, I have a script abc.sh which don't get terminated itself. So I need to design a script to run this script, save the output to a file, search for a given string in the output and if it exists send those... (11 Replies)
I have a shell script (.sh) and I want to pass a parameter value to the awk command but I am getting exception, please assist.
diff=$1$2.diff
id=$2 new=new_$diff
echo "My id is $1"
echo "I want to sync for user account $id"
##awk command I am using is as below
cat $diff | awk... (2 Replies)
Hi All,
I'm having some problems with my shell script. When running the script I get the following errors:
line 101: <html>: command not found
line 105: /dumpfile.txt: No such file or directory
The file dumpfile.txt does exist and I have double and tripple checked this. I'm not sure... (14 Replies)
Hello All,
I m trying to send mail from my unix script,
I have used the below command
mailx -s 'hi' email address < temp.txt
It is not giving me any error,but I couldn't receive the mail
Can you please help me.
Many Thanks,
Pragyan (6 Replies)
Hi All,
I want to send mail to multiple users..
Currently I am using below script
cat $STATUS_FILE|mailx -s "$SUBJECT" -r xxx@yyy.com $MAILTO
How can i give cc or bcc to in this script
Please help me
thanks in advance
Regards
RG (3 Replies)
Dear All,
we have a command output which looks like :
Total 200 queues in 30000 Kbytes
and we're going to get "200" and "30000" for further process. currently, i'm using :
numA=echo $OUTPUT | awk '{print $2}'
numB=echo $OUTPUT | awk '{print $5}'
my question is : can I use just one... (4 Replies)
Hi,
I need a shell script which runs in the backround for all the 24 hours and send a mail to us regarding the output of the prstat command when the load average increase above certain percent.
kindly help me on this...... (1 Reply)