1833210 Members
2922 Online
110051 Solutions
New Discussion

Re: scripting problem

 
shah.fuzail
Advisor

scripting problem

I have configured the following script which works suueccfully and gives me file system status update via email;
for i in 1 3 5 6 7 8 ; do
if [ `bdf /dev/vg00/lvol$i | awk {'print$5'} | cut -c 1,2 | tail -1` -gt 85 ]; t
hen
bdf /dev/vg00/lvol$i | awk {'print$5,$6'} > /root/detail.txt
mail fsalerts@telenor.com.pk < /root/detail.txt
fi
done

Now I want same alert via SMS but I can't understand who I fulfill the format of SMSC server, required format is like that;

[SMS]
TO=00923455001008
FROM=Shah Fuzail
Text=FS status

How can I fetch the critical file system notification from the existing script and cascade it with the SMS format file
12 REPLIES 12
Peter Godron
Honored Contributor

Re: scripting problem

Hi,
echo "[SMS]" > sms.file
echo "TO=00923455001008" >> sms.file
echo "FROM=Shah Fuzail" >> sms.file
echo "text=`cat /root/detail.txt`" >> sms.file

Would generate a file of that format.
Is this what you are after?
Tiziano Contorno _
Valued Contributor

Re: scripting problem

echo "[SMS]\nTO=00923455001008\nFROM=Shah Fuzail\nText=$(cat tmp.txt| xargs)"

xargs to have the Text on one line.

Is this what you mean/need?
Tiziano Contorno _
Valued Contributor

Re: scripting problem

tmp.txt stands for /root/detail.txt
shah.fuzail
Advisor

Re: scripting problem

Thanks for your prompt support but it may not resolve my issue, let me explain it as;
I have created a procedure which fulfill my requirement and it work like that;

create file test1 (contained SMSC required format)
create file test2 (contained text of File system alert)
1) cat test1 > smstest
2) cat test2 >> smstest
above procedure is giving me the required output, now I just need to call procedure in my exixting script to call this procedure everytime when file system exceed it limit and generate email message simutanously call SMS test procdure and execute it.

BR

Shah Fuzail
Peter Godron
Honored Contributor

Re: scripting problem

Hi,
call your procedure just after your existing mail command.
Then issue your SMS mail command with the smstest file as input.
shah.fuzail
Advisor

Re: scripting problem

yea now you on the right track, I just want to know the method how can I call procedure in my existing script.
I have no idea how procedure call in unix scripting.

Thx
Peter Godron
Honored Contributor

Re: scripting problem

Hi,
for example:
test1()
{
echo "hello"
}
echo "1"
test1
echo "2"

When run produces:
1
hello
2

Hope this answer helps.


shah.fuzail
Advisor

Re: scripting problem

Sorry to bother you again, your example is related with the procedure which I already wrote I just want to know how can I call this procedure in my existing script, my script is;

for i in 1 3 5 6 7 8 ; do
if [ `bdf /dev/vg00/lvol$i | awk {'print$5'} | cut -c 1,2 | tail -1` -gt 85 ]; t
hen
bdf /dev/vg00/lvol$i | awk {'print$5,$6'} > /root/detail.txt
mail fsalerts@telenor.com.pk < /root/detail.txt
fi
done

I want to call my procedure in between the above script, means just after the detail.txt file creation.

Thnx
Peter Godron
Honored Contributor

Re: scripting problem

Hi,
no problem.
yourproc()
{
#This is were you place your code
}
for i in 1 3 5 6 7 8 ; do
if [ `bdf /dev/vg00/lvol$i | awk {'print$5'} | cut -c 1,2 | tail -1` -gt 85 ]; t
hen
bdf /dev/vg00/lvol$i | awk {'print$5,$6'} > /root/detail.txt
yourproc
mail fsalerts@telenor.com.pk < /root/detail.txt
fi
done

If you are happy with the answer, please have a look at
http://forums1.itrc.hp.com/service/forums/helptips.do?#28
shah.fuzail
Advisor

Re: scripting problem

Thanks Peter;

Now it's working

BR

Shah
shah.fuzail
Advisor

Re: scripting problem

Thanks for the instant support

Now me script is working perfect.

Best regards,

Shah Fuzail Ahmed
Peter Godron
Honored Contributor

Re: scripting problem

Shah,
sorry to see none of my answers helped.
http://forums1.itrc.hp.com/service/forums/helptips.do?#28