Hello all !
Now is working for me throught script/crontab!

My faul, i didnt realise, i put the second line of my script ( sourte
/etc/profile ) and the script worked
perfect running in a root's crontab!
bellow the script ...
##### begin of script #############################
###########################################
#!/bin/bash
# by: Erik Gielow  epgielow at gmail dot com
###########################################
source /etc/profile

Initial_State=`/opt/CPsuite-R60/fw1/bin/cphaprob state |/bin/grep active
|/bin/awk '{print $1}'`
Temp_State=`/bin/cat /home/admin/scripts/finalState.log`

MAILSERVER=111.111.111.111 # your mail server

if [ $Initial_State != $Temp_State ]
then
/opt/CPsuite-R60/fw1/bin/sendmail -t $MAILSERVER -f [EMAIL PROTECTED]
[EMAIL PROTECTED] << END
Subject: Cluster Alert
From: [EMAIL PROTECTED]
Date: `/sbin/clock |/bin/awk '{print $1", "$3" "$2" "$5" "$4" -0300"}'`

Atencao: Mudanca de Firewall automatica...

`/opt/CPsuite-R60/fw1/bin/cphaprob state`

END
fi

#Atualiza a variavel de estado para proxima comparacao com o estado atual.
# translate to english :)
# update the state var to the next comparation with the actual state.

Final_State=`/opt/CPsuite-R60/fw1/bin/cphaprob state |/bin/grep active
|/bin/awk '{print $1}'`

Valor1=1
Valor2=2

# i chance do using cp, to avoid problems with cat, and noclobber settings.
# i use three adicional files, Valor1,Valor2 and finalState.log.

if [ $Final_State != $Valor1 ]
then
/bin/cp -f /home/admin/scripts/Valor2 /home/admin/scripts/finalState.log
else
/bin/cp -f /home/admin/scripts/Valor1 /home/admin/scripts/finalState.log
fi

###########END of script#################################


the values of files:
[EMAIL PROTECTED] cat Valor1; cat Valor2; cat finalState.log
1
2
1
[EMAIL PROTECTED]


Regards

Erik Gielow



On 10/18/07, Torkel Mathisen <[EMAIL PROTECTED]> wrote:
>
> Erik,
>
> I would very much like that script if that is possible.
>
> It would help me out a lot.
>
> -Torkel
>
> > -----Original Message-----
> > From: Mailing list for discussion of Firewall-1 [mailto:FW-1-
> > [EMAIL PROTECTED] On Behalf Of cisco4ng
> > Sent: Thursday, October 18, 2007 1:31 PM
> > To: [email protected]
> > Subject: Re: [FW-1] Alert when state of ClusterXL changes
> >
> > Hugo,
> >
> > Why don't you just tell him what the problem is?
> >
> > Erik, it is most likely that the problem you have is the script you
> > have does not have this line in it:
> >
> > sh /opt/CPshrd-R65/tmp/.CPprofile.sh (this is NGx R65)
> >
> > for more info, go to cd $CPDIR/tmp and you will find .CPprofile.sh and
> > .CPprofile.csh.  Depending on your script (csh or sh), you will put in
> > one of these lines and your script will work with crontab.
> >
> > I ran into a similar issue and didn't know how to fix it 'cause I am not
> > a programmer.  It took me about an hour to figure it out.
> >
> > good luck to you.
> >
> > Hugo van der Kooij <[EMAIL PROTECTED]> wrote: -----BEGIN PGP
> SIGNED
> > MESSAGE-----
> > Hash: SHA1
> >
> > Erik Gielow wrote:
> > > Thanks too!!
> > > I  tried to do this making a script shell, and running in a root
> > crontab,
> > >  the script are working 100% when i run manualy, the email with the
> > warning
> > > that the
> > > clusterxl A are down and B up etc ...
> > > but when i put the script in a crontab, i didnt receve any email ... i
> > > think, could be, the roots contrab are not allowed to send email
> ???  i
> > > really dont know ...
> > > this is the answer to this problem! i ll try latter!
> >
> > You propably rely on variables being set. But most of the ones that are
> > set when you login are not set when you run from crontab.
> >
> > You will find details about which script needs to be called from your
> > script in the archives.
> >
> > Hugo.
> >
> > - --
> > [EMAIL PROTECTED]               http://hugo.vanderkooij.org/
> > PGP/GPG? Use: http://hugo.vanderkooij.org/0x58F19981.asc
> >
> > Bored? Click on http://spamornot.org/ and rate those images.
> >
> > -----BEGIN PGP SIGNATURE-----
> > Version: GnuPG v1.4.7 (GNU/Linux)
> >
> > iD8DBQFHFwSDBvzDRVjxmYERAsG6AKCat+A9J51UzRLOwFL1A6QTM43+6ACfUf/N
> > 5jwL52+nBeau3+iYupj26GU=
> > =zzWg
> > -----END PGP SIGNATURE-----
> >
> > =================================================
> > To set vacation, Out-Of-Office, or away messages,
> > send an email to [EMAIL PROTECTED]
> > in the BODY of the email add:
> > set fw-1-mailinglist nomail
> > =================================================
> > To unsubscribe from this mailing list,
> > please see the instructions at
> > http://www.checkpoint.com/services/mailing.html
> > =================================================
> > If you have any questions on how to change your
> > subscription options, email
> > [EMAIL PROTECTED]
> > =================================================
> >
> >
> >  __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam protection around
> > http://mail.yahoo.com
> >
> > =================================================
> > To set vacation, Out-Of-Office, or away messages,
> > send an email to [EMAIL PROTECTED]
> > in the BODY of the email add:
> > set fw-1-mailinglist nomail
> > =================================================
> > To unsubscribe from this mailing list,
> > please see the instructions at
> > http://www.checkpoint.com/services/mailing.html
> > =================================================
> > If you have any questions on how to change your
> > subscription options, email
> > [EMAIL PROTECTED]
> > =================================================
>
> =================================================
> To set vacation, Out-Of-Office, or away messages,
> send an email to [EMAIL PROTECTED]
> in the BODY of the email add:
> set fw-1-mailinglist nomail
> =================================================
> To unsubscribe from this mailing list,
> please see the instructions at
> http://www.checkpoint.com/services/mailing.html
> =================================================
> If you have any questions on how to change your
> subscription options, email
> [EMAIL PROTECTED]
> =================================================
>



-- 
------------------------------------
Erik Gielow
SysAdmin - C.E.S.A.R.
------------------------------------

=================================================
To set vacation, Out-Of-Office, or away messages,
send an email to [EMAIL PROTECTED]
in the BODY of the email add:
set fw-1-mailinglist nomail
=================================================
To unsubscribe from this mailing list,
please see the instructions at
http://www.checkpoint.com/services/mailing.html
=================================================
If you have any questions on how to change your
subscription options, email
[EMAIL PROTECTED]
=================================================

Reply via email to