Operating System - HP-UX
1753906 Members
9104 Online
108810 Solutions
New Discussion юеВ

Re: grep lines under the event header

 
SOLVED
Go to solution
Jeeshan
Honored Contributor

Re: grep lines under the event header

I have changed my script Dennis. Helpful if you please correct it to set logic

#!/usr/bin/sh

SMS_RECEIVER=''
HS=$1
MAIL_RECEIVER=""
ssh @$1 bdf|awk 'NF==1{f=$0;getline;$0=f$0}{if($5+0>50)print}'|awk '{print $6 " " $5}'|sed 's/'%'/''/' > $1.bdf.info
print "File system warning of $HS server:" > $HS.mes.txt

function check_slash {
a=`cat $HS.bdf.info|grep -w /`
b=`cat $HS.bdf.info|grep -w /|awk '{print $2}'`
if [[ $b > `expr 55` ]]
then
print "$a%" >> $HS.mes.txt
fi
}
check_slash

function sms {
if [[ -f $HS.mes.txt ]]
then
# /usr/local/bin/lynx -dump `$SMS_RECEIVER `cat $HS.mes.txt``
#/usr/local/bin/lynx -dump "$SMS_RECEIVER `cat $HS.mes.txt`"
mailx -s "File System warning of $HS server:" $MAIL_RECEIVER < $HS.mes.txt

fi

}
sms

I will run the script like this

file.sh
a warrior never quits
Dennis Handly
Acclaimed Contributor

Re: grep lines under the event header

>I have changed my script

#!/usr/bin/sh
SMS_RECEIVER=''
HS=$1
MAIL_RECEIVER=""

function check_slash {
a=$(grep -w / $HS.bdf.info)
b=$(grep -w / $HS.bdf.info | awk '{print $2}')
if [ $b -gt 55 ]; then
    if [ ! -f $HS.reported ]; then
        echo 55 > $HS.reported
    fi
    # report if larger
    if [ $b -gt $(< $HS.reported) ]; then
        print $b% >> $HS.mes.txt
    else
        rm -f $HS.mes.txt
    fi
    echo $b > $HS.reported
else
    rm -f $HS.mes.txt $HS.reported
fi
}

function sms {
if [[ -f $HS.mes.txt ]]; then
    # /usr/local/bin/lynx -dump $($SMS_RECEIVER $(< $HS.mes.txt) )
    #/usr/local/bin/lynx -dump "$SMS_RECEIVER $(< $HS.mes.txt)"
    mailx -s "File System warning of $HS server:" \
    $MAIL_RECEIVER < $HS.mes.txt
fi
}

ssh @$1 bdf | awk '
NF==1 {f=$0; getline; $0=f$0}
{if ($5+0 > 50) print $6, $5 }' | sed 's/%//' > $HS.bdf.info
print "File system warning of $HS server:" > $HS.mes.txt

check_slash
sms

As JRF mentioned move the functions to the top and just invoke their names.

(I wasn't sure why you had stuttered your single quotes in sed?)

Jeeshan
Honored Contributor

Re: grep lines under the event header

Hey Dennis
thanks buddy.

Really appreciate your thought. But i have slightly changed the logic. Its working now.

Hope to get further help from you.

a warrior never quits
Jeeshan
Honored Contributor

Re: grep lines under the event header

another issue.

Create a shell script which will edit a file content which have some syntax. An user must call this script to modify the file and while saving it will first notify to the group owner of that file. If the owner permit him the script will than save the changes in that file and push the file on all servers.
a warrior never quits
Dennis Handly
Acclaimed Contributor

Re: grep lines under the event header

>Create a shell script which will edit a file content which have some syntax.

This is vague. Make changes to a copy so you can do the rest.

>it will first notify to the group owner of that file. If the owner permit him the script will than save the changes in that file

You are actually going to send mail to the group owner? Or are you going to check the group permissions and overwrite it anyway if you can?

>push the file on all servers.

Look into rdist?
James R. Ferguson
Acclaimed Contributor

Re: grep lines under the event header

Hi:

> another issue

Instead of continuing to add new questions to this thread, you need to create a _NEW_ thread. Part of the value of this community is in being ablt to search threads for solutions and suggested in part based on the original subject. You now have three totally separate questions.

Regards!

...JRF...