Re: how to do scripting "for X in $LIST"

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
No need for awk:<br>
<br>
Joe Philip wrote:
<blockquote cite="mid:_Ya0b.6873$N37.6552 [at] nwrdny02.gnilink.net"
type="cite">
<meta http-equiv="Content-Type" content="text/html; ">
<meta content="MSHTML 6.00.2800.1106" name="GENERATOR">
<style></style>
<div><font face="Arial" size="2">I have a script to check the "df
-k" output. Some of our mount points are permanently 100% full. I
want to check all the mount points except the ones which are in my
list.</font></div>
<div> </div>
<div><font face="Arial" size="2">For example, I want to modify the
following script so that it checks all the mount points which are
more than 98% full except the ones on the FULL_LIST. What is the
corrent syntax to do this line:</font></div>
<div><font face="Arial" size="2">     <font color="#ff0000">if  [
mnt_pt not in $FULL_LIST ]; then</font></font></div>
<div> </div>
<div><font face="Arial" size="2"> ------------------------------------------------------------ ---------------------------------</font></div>
<div>
<p><font face="Arial" size="2">#!/bin/ksh</font></p>
<p><font color="#ff0000" face="Arial" size="2">FULL_LIST="/u110
/u05"</font></p>
<p><font face="Arial" size="2">df -k | grep -iv filesystem | awk '{
print $6" "$5}' | while read LINE; do</font></p>
</div>
</blockquote>
df -k |\<br>
while read -A REC; do<br>
    [[ ${REC[5]} == +([[:digit:]]) || && ${REC[6]} ==
+([[:digit:])) ]] || continue<br>
    print Do something here.<br>
done<br>
<blockquote cite="mid:_Ya0b.6873$N37.6552 [at] nwrdny02.gnilink.net"
type="cite">
<div>
<p><font face="Arial" size="2">PERC=`echo $LINE | cut -d"%" -f1 |
awk '{ print $2 }'`</font></p>
<p><font face="Arial" size="2">TST=`echo $LINE | cut -d"%" -f1 |
awk '{ print $1 }'`</font></p>
<p><font face="Arial" size="2">if [ $PERC -gt 98 ]; then</font></p>
<p><font face="Arial" size="2">    <font color="#ff0000">if  [
mnt_pt not in $FULL_LIST ]; then</font></font></p>
<p><font face="Arial" size="2">    echo "${PERC}% ALERT" | Mail -s
"${LINE} on `hostname` is almost full"  </font><a
moz-do-not-send="true" href="mailto:mail [at] mail.com"><font face="Arial"
size="2">mail [at] mail.com</font></a></p>
<p><font face="Arial" size="2">    fi</font></p>
<p><font face="Arial" size="2">fi</font></p>
<p><font face="Arial" size="2">done</font></p>
</div>
<div> </div>
</blockquote>
<br>
</body>
</html>
bmynars [ Fr, 26 Oktober 2007 06:04 ] [ ID #1854881 ]

Re: how to do scripting "for X in $LIST"

On 2007-10-26, Bolek Mynarski <bmynars [at] gmail.com> wrote:
><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
><html>
><head>

Please don't do this. Usenet is a plain text medium.

--
"Be thankful that you have a life, and forsake your vain
and presumptuous desire for a second one."
[email me at huge {at} huge (dot) org <dot> uk]
huge [ Fr, 26 Oktober 2007 09:40 ] [ ID #1854884 ]

Re: how to do scripting "for X in $LIST"

Bolek Mynarski wrote:
> No need for awk:
>
> Joe Philip wrote:
>> I have a script to check the "df -k" output. Some of our mount points
>> are permanently 100% full. I want to check all the mount points except
>> the ones which are in my list.
>>
>> For example, I want to modify the following script so that it checks
>> all the mount points which are more than 98% full except the ones on
>> the FULL_LIST. What is the corrent syntax to do this line:
>> if [ mnt_pt not in $FULL_LIST ]; then
>>
>> ------------------------------------------------------------ ---------------------------------
>>
>> #!/bin/ksh
>>
>> FULL_LIST="/u110 /u05"
>>
>> df -k | grep -iv filesystem | awk '{ print $6" "$5}' | while read LINE; do
>>
> df -k |\
> while read -A REC; do
> [[ ${REC[5]} == +([[:digit:]]) || && ${REC[6]} == +([[:digit:])) ]]
> || continue
> print Do something here.
> done
>>
>> PERC=`echo $LINE | cut -d"%" -f1 | awk '{ print $2 }'`
>>
>> TST=`echo $LINE | cut -d"%" -f1 | awk '{ print $1 }'`
>>
>> if [ $PERC -gt 98 ]; then
>>
>> if [ mnt_pt not in $FULL_LIST ]; then
>>
>> echo "${PERC}% ALERT" | Mail -s "${LINE} on `hostname` is almost
>> full" mail [at] mail.com <mailto:mail [at] mail.com>
>>
>> fi
>>
>> fi
>>
>> done
>>
>>
>

case $FULL_LIST in
*$mnt_pt*)
;; # excluded
*)
echo do something with $mnt_pt
;;
esac

To make the match more exact, you should do
FULL_LIST=" /u110 /u05 "

and use the match
*\ $mnt_pt\ *)


--
Michael Tosch [at] hp : com
Michael Tosch [ Fr, 26 Oktober 2007 10:49 ] [ ID #1854886 ]

Re: how to do scripting "for X in $LIST"

On Fri, 26 Oct 2007 00:04:12 -0400, Bolek Mynarski wrote:
> !DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> html>
> head>
> <meta content="text/html;charset=ISO-8859-1"
> http-equiv="Content-Type">
></head>
><body bgcolor="#ffffff" text="#000000">
> No need for awk:<br>

And, definitely *no* need for HTML in usenet.
Allodoxaphobia [ Sa, 27 Oktober 2007 04:37 ] [ ID #1855692 ]
Linux » comp.unix.shell » Re: how to do scripting "for X in $LIST"

Vorheriges Thema: E-mail from Solaris to W2K Outlook Express
Nächstes Thema: command substitution and the pipe