Re: [expert] Detecting an Active Network Interface

2002-08-21 Thread Ronald J. Hall

On Tuesday 20 August 2002 11:04 pm, you wrote:

> Randy,
>
> it is written: "thou shalt NOT use a GOTO...ever!" ;) The force fed us
> that in assembler and COBOL classes till I thought it was gonna come
> outa my ears.

and especially with the label: HELL !!!



-- 
  /\
   Dark>

Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com



Re: [expert] Detecting an Active Network Interface

2002-08-21 Thread Brandon Long

I use something similiar to this script to check connectivity across my 
network. With a mysql backend it has become a very useful tool. Only problem 
is when you try to ping firewalled hosts. If you are on the same lan segment 
arping can be very useful because it works on the mac layer instead of the 
tcp/ip layer, can ping through most firewalls unless it is a mac oriented 
iptables firewall.


On Tuesday 20 August 2002 11:06 pm, Mark Weaver wrote:
> Randy Kramer wrote:
> > kwan,
> >
> > Thanks!  I've got several choices now ;-)
> >
> > Randy Kramer
> >
> > [EMAIL PROTECTED] wrote:
> >>Here's a script that I use to check connectivity:
> >>
> >>
> >>  #!/bin/bash
> >>  STATUS=`ping -c 2 -q 11.22.33.44 2>/dev/null`
> >>  CODE=$?
> >>
> >>  if [ $CODE -gt 0 ]; then
> >> echo Link is down.
> >>  else
> >> echo Link is up.
> >>  fi
> >>
> >>
> >>Replace the 11.22.33.44 with a host on the internet. I use the
> >>nameserver of the ISP but you can use any reliable address.
> >>This script segment is part of a larger one to reboot my DSL modem via
> >>X10, but you can modify it for dialup. There are also other ways of
> >>dialing on demand such as "diald" that may be more effective.
>
> Randy,
>
> The above was the accurate rendition of the correct syntax for the
> earlier suggestion.

-- 
Brandon Long
[EMAIL PROTECTED]



Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com



Re: [expert] Detecting an Active Network Interface

2002-08-21 Thread Mark Weaver

Todd Lyons wrote:
> Mark Weaver wrote on Tue, Aug 20, 2002 at 11:04:16PM -0400 :
> 
>>>So ("thinking on paper"), something like:
>>
> 
> 
>>>  if count <= maxtries (wow, do I forget valid syntax ;-) )
>>> then
>>>wait 30 (??) (give the modem a chance to connect)
>>>goto start
>>> else
>>>issue "Internet connection lost, could not restart"
>>>message (somewhere)
>>>  fi
>>
> 
> 
>>>I'll need to brush up on bash syntax and so forth, and if I'm clever I
>>>might get rid of the goto. 
>>
>>it is written: "thou shalt NOT use a GOTO...ever!" ;) The force fed us 
>>that in assembler and COBOL classes till I thought it was gonna come 
>>outa my ears.
> 
> 
> [root@fiji /usr/src/linux/kernel]# grep "goto.*\;$" * | wc -l
> 187
> 
> Comments? :)  Don't tell me Linus doesn't know anything about c now :)
> 
> Blue skies... Todd

Todd,

don't know what goto's are like in C, but they suck in mainframe 
Assembler and COBOL. looking at older code it gets so bad sometimes 
depending on the author that it's easier just to rewrite the stinkin thing.

-- 
daRmaTTeR

Reg. Linux User #186492
"Stupidity has no moral high ground...it can't see that high!"




Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com



Re: [expert] Detecting an Active Network Interface

2002-08-20 Thread J. Craig Woods

Todd Lyons wrote:
> 
> Mark Weaver wrote on Tue, Aug 20, 2002 at 11:04:16PM -0400 :
> > >So ("thinking on paper"), something like:
> 
> > >   if count <= maxtries (wow, do I forget valid syntax ;-) )
> > >  then
> > > wait 30 (??) (give the modem a chance to connect)
> > > goto start
> > >  else
> > > issue "Internet connection lost, could not restart"
> > >message (somewhere)
> > >   fi
> 
> > >I'll need to brush up on bash syntax and so forth, and if I'm clever I
> > >might get rid of the goto.
> > it is written: "thou shalt NOT use a GOTO...ever!" ;) The force fed us
> > that in assembler and COBOL classes till I thought it was gonna come
> > outa my ears.
> 
> [root@fiji /usr/src/linux/kernel]# grep "goto.*\;$" * | wc -l
> 187
> 
> Comments? :)  Don't tell me Linus doesn't know anything about c now :)
> 

201 on my system...

Ya, and who says you can't teach an old dog new tricks, even Linus is
forever into change...

drjung

-- 
J. Craig Woods
UNIX/NT Network/System Administration
http://www.trismegistus.net/resume.html
Character is built upon the debris of despair --Emerson



Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com



Re: [expert] Detecting an Active Network Interface

2002-08-20 Thread Todd Lyons

Mark Weaver wrote on Tue, Aug 20, 2002 at 11:04:16PM -0400 :
> >So ("thinking on paper"), something like:

> >   if count <= maxtries (wow, do I forget valid syntax ;-) )
> >  then
> > wait 30 (??) (give the modem a chance to connect)
> > goto start
> >  else
> > issue "Internet connection lost, could not restart"
> >message (somewhere)
> >   fi

> >I'll need to brush up on bash syntax and so forth, and if I'm clever I
> >might get rid of the goto. 
> it is written: "thou shalt NOT use a GOTO...ever!" ;) The force fed us 
> that in assembler and COBOL classes till I thought it was gonna come 
> outa my ears.

[root@fiji /usr/src/linux/kernel]# grep "goto.*\;$" * | wc -l
187

Comments? :)  Don't tell me Linus doesn't know anything about c now :)

Blue skies...   Todd
-- 
  Todd Lyons -- MandrakeSoft, Inc.   http://www.mandrakesoft.com/
UNIX was not designed to stop you from doing stupid things, because 
  that would also stop you from doing clever things. -- Doug Gwyn
   Cooker Version mandrake-release-9.0-0.3mdk Kernel 2.4.19-4mdk



msg57149/pgp0.pgp
Description: PGP signature


Re: [expert] Detecting an Active Network Interface

2002-08-20 Thread Mark Weaver

Randy Kramer wrote:
> kwan,
> 
> Thanks!  I've got several choices now ;-)
> 
> Randy Kramer
> 
> [EMAIL PROTECTED] wrote:
> 
>>Here's a script that I use to check connectivity:
>>
>>
>>  #!/bin/bash
>>  STATUS=`ping -c 2 -q 11.22.33.44 2>/dev/null`
>>  CODE=$?
>>
>>  if [ $CODE -gt 0 ]; then
>> echo Link is down.
>>  else
>> echo Link is up.
>>  fi
>>
>>
>>Replace the 11.22.33.44 with a host on the internet. I use the
>>nameserver of the ISP but you can use any reliable address.
>>This script segment is part of a larger one to reboot my DSL modem via
>>X10, but you can modify it for dialup. There are also other ways of
>>dialing on demand such as "diald" that may be more effective.

Randy,

The above was the accurate rendition of the correct syntax for the 
earlier suggestion.

-- 
daRmaTTeR

Reg. Linux User #186492
"Stupidity has no moral high ground...it can't see that high!"




Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com



Re: [expert] Detecting an Active Network Interface

2002-08-20 Thread Mark Weaver

Randy Kramer wrote:
> daRcmaTTeR wrote:
> 
>>What if you just did something like this.
>>
>>1) ping ISP...
>> a) if icmp echo request == 'yes'
>>then
>>do the mail thing
>>else
>>run "ifup" command kick mailque
>>   fi
>>
>>what-cha think?
> 
> 
> daRcmaTTeR,
> 
> Thanks very much -- it's a good start if not more!
> 
> I guess I'll find out for sure soon ;-) , but is that "if icmp echo
> request == 'yes'" pretty close to the right syntax?  (I assume it's
> checking for success of the ping.)  Hmm, I looked up man icmp and man
> echo -- looks like I'll have to dig a little deeper or do an experiment
> or two.
> 
> (Just for the record, I don't need (and can't use) the ifup command
> (effectively) as the dial up modem is on another box (running under
> dos).  The ping should "kick" the modem (except that, occasionally, the
> modem hangs up and "locks up" so it won't redial).  I'll probably
> arrange the script to ping, check for success, on success kick the
> mailqueue, on failure wait, then retry the ping.)
> 
> So ("thinking on paper"), something like:
> 
>maxtries = 3 (??) 
>count = 0
> start: ping ISP (with parameters to limit to say 4 pings instead of
> continuous)
>count = count + 1
>  if icmp echo request == 'yes'
> then
>fetchmail 
>sendmail -q
> else
>if count <= maxtries (wow, do I forget valid syntax ;-) )
>   then
>  wait 30 (??) (give the modem a chance to connect)
>  goto start
>   else
>  issue "Internet connection lost, could not restart"
> message (somewhere)
>fi
>  fi
> 
> I'll need to brush up on bash syntax and so forth, and if I'm clever I
> might get rid of the goto. 
> 
> regards,
> Randy Kramer

Randy,

it is written: "thou shalt NOT use a GOTO...ever!" ;) The force fed us 
that in assembler and COBOL classes till I thought it was gonna come 
outa my ears.

-- 
daRmaTTeR

Reg. Linux User #186492
"Stupidity has no moral high ground...it can't see that high!"




Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com



Re: [expert] Detecting an Active Network Interface

2002-08-15 Thread Randy Kramer

kwan,

Thanks!  I've got several choices now ;-)

Randy Kramer

[EMAIL PROTECTED] wrote:
> Here's a script that I use to check connectivity:
> 
> 
>   #!/bin/bash
>   STATUS=`ping -c 2 -q 11.22.33.44 2>/dev/null`
>   CODE=$?
> 
>   if [ $CODE -gt 0 ]; then
>  echo Link is down.
>   else
>  echo Link is up.
>   fi
> 
> 
> Replace the 11.22.33.44 with a host on the internet. I use the
> nameserver of the ISP but you can use any reliable address.
> This script segment is part of a larger one to reboot my DSL modem via
> X10, but you can modify it for dialup. There are also other ways of
> dialing on demand such as "diald" that may be more effective.



Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com



Re: [expert] Detecting an Active Network Interface

2002-08-15 Thread Randy Kramer

daRcmaTTeR wrote:
> What if you just did something like this.
> 
> 1) ping ISP...
>  a) if icmp echo request == 'yes'
> then
> do the mail thing
> else
> run "ifup" command kick mailque
>fi
> 
> what-cha think?

daRcmaTTeR,

Thanks very much -- it's a good start if not more!

I guess I'll find out for sure soon ;-) , but is that "if icmp echo
request == 'yes'" pretty close to the right syntax?  (I assume it's
checking for success of the ping.)  Hmm, I looked up man icmp and man
echo -- looks like I'll have to dig a little deeper or do an experiment
or two.

(Just for the record, I don't need (and can't use) the ifup command
(effectively) as the dial up modem is on another box (running under
dos).  The ping should "kick" the modem (except that, occasionally, the
modem hangs up and "locks up" so it won't redial).  I'll probably
arrange the script to ping, check for success, on success kick the
mailqueue, on failure wait, then retry the ping.)

So ("thinking on paper"), something like:

   maxtries = 3 (??) 
   count = 0
start: ping ISP (with parameters to limit to say 4 pings instead of
continuous)
   count = count + 1
 if icmp echo request == 'yes'
then
   fetchmail 
   sendmail -q
else
   if count <= maxtries (wow, do I forget valid syntax ;-) )
  then
 wait 30 (??) (give the modem a chance to connect)
 goto start
  else
 issue "Internet connection lost, could not restart"
message (somewhere)
   fi
 fi

I'll need to brush up on bash syntax and so forth, and if I'm clever I
might get rid of the goto. 

regards,
Randy Kramer



Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com



Re: [expert] Detecting an Active Network Interface

2002-08-15 Thread kwan

On Thu, 15 Aug 2002, Randy Kramer wrote:

> I'm getting close on my email server (using fetchmail, postfix,
> procmail, ipopd (and maybe later imapd) -- in fact, if you see this it
> came from my Windows box via the Linux email server. ;-)
> 
> But, I have some bugs to work out yet, and some questions:
> 
> Questions:
> 
> 1.  Anybody know a good way to detect that a network link is active?  
> Background:
> 
> My connection to the Internet is via a dial up on another box (Dos, as a
> matter of fact.)  I would like to set up a cron job (and script) to do
> something like the following:
>* Confirm the connection to my ISP is up (ping him, check for
> success?)
>* If no: wake it up (ping it), and after so many tries, quit and give
> a message somewhere (and if it wakes up, proceed to the if yes)
>* If yes:
>   * Run fetchmail to get mail
>   * Run sendmail -q to kick the queue and send any outgoing mail
> (I've set defer_transports=SMTP)
> 
> The reason I want to make sure the link is up before I kick the queue is
> so that the "exponential backoff" doesn't go into effect and result in
> outgoing messages sitting in the server for long periods of time (or
> even getting "failure to deliver" "bounces" from my own server).
> 
> Is that an unrealistic concern?  Is there a better way to deal with it?
> 

Here's a script that I use to check connectivity:


  #!/bin/bash  
  STATUS=`ping -c 2 -q 11.22.33.44 2>/dev/null`
  CODE=$?

  if [ $CODE -gt 0 ]; then
 echo Link is down.
  else
 echo Link is up. 
  fi
  
  
Replace the 11.22.33.44 with a host on the internet. I use the
nameserver of the ISP but you can use any reliable address.
This script segment is part of a larger one to reboot my DSL modem via
X10, but you can modify it for dialup. There are also other ways of
dialing on demand such as "diald" that may be more effective.




Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com



Re: [expert] Detecting an Active Network Interface

2002-08-15 Thread daRcmaTTeR

On Thu, 15 Aug 2002, Randy Kramer wrote:

> I'm getting close on my email server (using fetchmail, postfix,
> procmail, ipopd (and maybe later imapd) -- in fact, if you see this it
> came from my Windows box via the Linux email server. ;-)
> 
> But, I have some bugs to work out yet, and some questions:
> 
> Questions:
> 
> 1.  Anybody know a good way to detect that a network link is active?  
> Background:
> 
> My connection to the Internet is via a dial up on another box (Dos, as a
> matter of fact.)  I would like to set up a cron job (and script) to do
> something like the following:
>* Confirm the connection to my ISP is up (ping him, check for
> success?)
>* If no: wake it up (ping it), and after so many tries, quit and give
> a message somewhere (and if it wakes up, proceed to the if yes)
>* If yes:
>   * Run fetchmail to get mail
>   * Run sendmail -q to kick the queue and send any outgoing mail
> (I've set defer_transports=SMTP)
> 
> The reason I want to make sure the link is up before I kick the queue is
> so that the "exponential backoff" doesn't go into effect and result in
> outgoing messages sitting in the server for long periods of time (or
> even getting "failure to deliver" "bounces" from my own server).
> 
> Is that an unrealistic concern?  Is there a better way to deal with it?
> 
> Randy Kramer
> 
> Aside: For a while, every time someone mentioned "ifup" it sounded like
> just what I needed.  I now realize that it is a command (bring the
> interface up) rather than a test (if the interface is up, do ...)
 
Hi Randy,

What if you just did something like this.

1) ping ISP...
 a) if icmp echo request == 'yes'
then
do the mail thing
else
run "ifup" command kick mailque
   fi

what-cha think? 

-- 
daRmaTTeR

Reg. Linux User #186492
"Stupidity has no moral high ground...it can't see that high!"




Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com