#1  
Old 21st June 2006, 17:33
xrtc xrtc is offline
Junior Member
 
Join Date: Mar 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default scirpt problem

What i do wrong???
#!/bin/bash
PROXY=`ping 192.168.1.1 -c 1 | grep 100`
if [ ! "$PROXY" ]
then
{
if [ $chk=1 ]
then
{
echo OK
chk=1
}
else
if [ $chk=0 ]
then
{
echo "gnet still down"
}
else
echo "gnet down" | sendmail xrtc@megabyte.gr
echo "gnet down"
fi
fi
}
else exit
fi

also in rc.local i have chk=1
i want to send me mail if the proxy ip is not respoding... 1 mail only
this scprit will run as cronjob every 5 minutes

Thanks in advance
XRtC
Reply With Quote
  #2  
Old 22nd June 2006, 16:03
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 31,843
Thanks: 781
Thanked 1,557 Times in 1,476 Posts
Default

What exactly is the problem? Any error messages?
__________________
Falko
--
Follow me on:
Reply With Quote
  #3  
Old 23rd June 2006, 17:19
Crusader Crusader is offline
Junior Member
 
Join Date: May 2006
Location: UK
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Crusader Send a message via Skype™ to Crusader
Default This works

Quote:
Originally Posted by xrtc
What i do wrong???
#!/bin/bash
PROXY=`ping 192.168.1.1 -c 1 | grep 100`
if [ ! "$PROXY" ]
then
{
if [ $chk=1 ]
then
{
echo OK
chk=1
}
else
if [ $chk=0 ]
then
{
echo "gnet still down"
}
else
echo "gnet down" | sendmail xrtc@megabyte.gr
echo "gnet down"
fi
fi
}
else exit
fi

also in rc.local i have chk=1
i want to send me mail if the proxy ip is not respoding... 1 mail only
this scprit will run as cronjob every 5 minutes

Thanks in advance
XRtC
Firstly, If you structure your code a little more, then you will be able to see where things aren't quite right.

My example should give you the idea of indenting your code blocks. My example, provides you with a simple IP address check. I am not sure if this is what you want, but it does work. The script could be optimised, but I have made it simple for you to see exactly whats going on.

Code:
#!/bin/bash
IPADDRESS='192.168.1.1'
PROXY=`ping $IPADDRESS -c 1`
PROXY1=`ping $IPADDRESS -c 1 | grep 1\ received`
echo "$PROXY"
echo "$PROXY1"
if [ "$PROXY" ]; then
        if [ "$PROXY1" ]; then
			echo "OK"
		else
			echo "gnet down" | sendmail -t xrtc@megabyte.gr
			echo "gnet down"
        fi
fi
Hope this helps.

Crusader
__________________
Crusader
Crusading for WWW Excellence
www.seocrusade.com
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
sending e-mail using mail() function linuxuser1 HOWTO-Related Questions 38 21st April 2009 13:20
postfix problems with smtp linkdeb Server Operation 9 24th October 2006 18:12
Postfix+MySQL Problem jasutton Installation/Configuration 1 15th June 2006 17:06
Strange email problem for one of my domains... any help appreciated paulrobert_a Installation/Configuration 4 14th January 2006 11:01
SMTP TLS Problem with Mail Client dschmid Installation/Configuration 1 9th December 2005 02:56


All times are GMT +2. The time now is 12:07.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Sponsored Links: Unified Communications: Thoughts, Strategies and Predictions
Join the discussion.
www.seamlessenterprise.com

IP Convergence
Integrate your wireless and wireline networks.
Learn how from the experts at Sprint.
www.seamlessenterprise.com

Wireless & Wireline Integration
Thoughts, strategies and solutions: join the discussion
www.seamlessenterprise.com

Unified Communications 2009
Join the Discussion. Now.
www.seamlessenterprise.com

Red Hat Virtual Experience - a free virtual event. Dec. 9th