Help!

Auto network re-connect


Goto page Previous  1, 2
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> UK RSS
Next:  [Samba] [Urgent] Cannot make changes via pdbedit  
Author Message
Folderol
External


Since: Dec 13, 2004
Posts: 118



PostPosted: Sat Jul 21, 2007 7:16 pm    Post subject: Re: Auto network re-connect [Login to view extended thread Info.]
Archived from groups: uk>comp>os>linux (more info?)

On Sat, 21 Jul 2007 18:24:46 +0100
Nix <nix-razor-pit RemoveThis @esperi.org.uk> wrote:

> On 21 Jul 2007, folderol RemoveThis @ukfsn.org outgrape:
> > Hmmm. That would make things a bit neater:
> >
> > #!/bin/sh
> >
> > if [ `cat /sys/class/net/eth0/carrier` = "0" ];
> > then sudo /usr/sbin/ethtool -r eth0;
> > fi
>
> Alternatively, try
>
> if [[ "x$(cat /sys/class/net/eth0/carrier)" = "x0" ]]; then
> sudo /usr/sbin/ethtool -r eth0;
> fi
>
> (significantly faster with many shells, although not bash, and doesn't
> collapse with a syntax error if the carrier file doesn't exist or by
> some oddity contains something which requires quoting to avoid being
> seen as a shell metacharacter.)

Thanks. That's very sneaky Smile I can see how the 'x' ensures there is
always something valid to compare, and presumably the round brackets
take the place of the back ticks in some way, but how does the double
square bracketing help?


--
Will J G
Back to top
Jamin Davis
External


Since: Jul 17, 2007
Posts: 4



PostPosted: Sat Jul 21, 2007 10:30 pm    Post subject: Re: Auto network re-connect [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Friday 20 Jul 2007 20:43 Folderol <folderol.TakeThisOut@ukfsn.org> wrote:

>> Educate this person. Far simpler than trying to find a technological
>> solution.
> A technical solution is the *only* one acceptable. There is office
> politics involved. We are carefully trying to forstall the killer
> statement:
> Apparently, XP notifies you when the connection breaks, and also when
> it is available again and has reconnected.

I had this complaint from ex-MS types and found that KDE has an extremely
Windows-like network monitor 'tool' which displays the net connections in
the systray using ifconfig/iwconfig/route (knemo). If I switch off the
router I get two little ex'es against the icons and a tooltip popop "Not
Connected": switching the router back on pops up "eth0/1 connected" (or
whatever, its configurable).

--
Jamin @ Home: Chester UK -<jamin.TakeThisOut@ghost.merseine.nu>
Back to top
Folderol
External


Since: Dec 13, 2004
Posts: 118



PostPosted: Sun Jul 22, 2007 12:42 am    Post subject: Re: Auto network re-connect [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Sat, 21 Jul 2007 22:30:42 +0100
Jamin Davis <jweb.RemoveThis@ghost.merseine.nu> wrote:

> Friday 20 Jul 2007 20:43 Folderol <folderol.RemoveThis@ukfsn.org> wrote:
>
> >> Educate this person. Far simpler than trying to find a technological
> >> solution.
> > A technical solution is the *only* one acceptable. There is office
> > politics involved. We are carefully trying to forstall the killer
> > statement:
> > Apparently, XP notifies you when the connection breaks, and also when
> > it is available again and has reconnected.
>
> I had this complaint from ex-MS types and found that KDE has an extremely
> Windows-like network monitor 'tool' which displays the net connections in
> the systray using ifconfig/iwconfig/route (knemo). If I switch off the
> router I get two little ex'es against the icons and a tooltip popop "Not
> Connected": switching the router back on pops up "eth0/1 connected" (or
> whatever, its configurable).

Ah, this is very helpful. I'd much rather use something like this than
try to cobble something together that only does half the job!

--
Will J G
Back to top
Ben Bacarisse
External


Since: Jun 10, 2005
Posts: 90



PostPosted: Sun Jul 22, 2007 2:13 am    Post subject: Re: Auto network re-connect [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Folderol <folderol RemoveThis @ukfsn.org> writes:

> On Sat, 21 Jul 2007 22:30:42 +0100
> Jamin Davis <jweb RemoveThis @ghost.merseine.nu> wrote:
>
>> Friday 20 Jul 2007 20:43 Folderol <folderol RemoveThis @ukfsn.org> wrote:
>>
>> >> Educate this person. Far simpler than trying to find a technological
>> >> solution.
>> > A technical solution is the *only* one acceptable. There is office
>> > politics involved. We are carefully trying to forstall the killer
>> > statement:
>> > Apparently, XP notifies you when the connection breaks, and also when
>> > it is available again and has reconnected.
>>
>> I had this complaint from ex-MS types and found that KDE has an extremely
>> Windows-like network monitor 'tool' which displays the net connections in
>> the systray using ifconfig/iwconfig/route (knemo). If I switch off the
>> router I get two little ex'es against the icons and a tooltip popop "Not
>> Connected": switching the router back on pops up "eth0/1 connected" (or
>> whatever, its configurable).
>
> Ah, this is very helpful. I'd much rather use something like this than
> try to cobble something together that only does half the job!

This is indeed what KDE does, but I did not suggest that since I
assumed you were not using KDE (you'd have seen it doing it you
were!).

For the Gnome world, there is NetworkManager and its applet
nm-applet. I am pretty sure it can do the same thing (I have not used
it for a while) but the down side is that it lets your users break
things by be able o configure their network settings. This is often
fine, but in an environment where switching off the router is
problem...

Anyway, it may be worth a look.

--
Ben.
Back to top
Nix
External


Since: Jul 29, 2004
Posts: 680



PostPosted: Sun Jul 22, 2007 2:33 pm    Post subject: Re: Auto network re-connect [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 21 Jul 2007, folderol DeleteThis @ukfsn.org told this:
> On Sat, 21 Jul 2007 18:24:46 +0100
> Nix <nix-razor-pit DeleteThis @esperi.org.uk> wrote:
>> if [[ "x$(cat /sys/class/net/eth0/carrier)" = "x0" ]]; then
>> sudo /usr/sbin/ethtool -r eth0;
>> fi
>>
>> (significantly faster with many shells, although not bash, and doesn't
>> collapse with a syntax error if the carrier file doesn't exist or by
>> some oddity contains something which requires quoting to avoid being
>> seen as a shell metacharacter.)
>
> Thanks. That's very sneaky Smile I can see how the 'x' ensures there is
> always something valid to compare,

Look at the chapter `Shellology' in the autoconf manual. There's all
sorts of tricks like this.

> and presumably the round brackets
> take the place of the back ticks in some way,

$(...) is the POSIX replacement for `...`: unlike backticks, it nests.

(and $((...)) is maths.)

> but how does the double
> square bracketing help?

On many shells (Solaris ksh, for instance) [[ ]] is a shell builtin where
[ ] is not, and thus is far faster. (bash, ksh, pdksh, and recent kshs
have [ ] as a shell builtin too, but I have to write a lot of code that
runs on lesser platforms, so I've got used to [[ ]]...)
Back to top
Folderol
External


Since: Dec 13, 2004
Posts: 118



PostPosted: Sun Jul 22, 2007 2:36 pm    Post subject: Re: Auto network re-connect [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Sun, 22 Jul 2007 02:24:54 +0100
Ben Bacarisse <ben.usenet.RemoveThis@bsb.me.uk> wrote:

> Folderol <folderol.RemoveThis@ukfsn.org> writes:
>
> > On Sat, 21 Jul 2007 22:30:42 +0100
> > Jamin Davis <jweb.RemoveThis@ghost.merseine.nu> wrote:
> >
> >> Friday 20 Jul 2007 20:43 Folderol <folderol.RemoveThis@ukfsn.org> wrote:
> >>
> >> >> Educate this person. Far simpler than trying to find a technological
> >> >> solution.
> >> > A technical solution is the *only* one acceptable. There is office
> >> > politics involved. We are carefully trying to forstall the killer
> >> > statement:
> >> > Apparently, XP notifies you when the connection breaks, and also when
> >> > it is available again and has reconnected.
> >>
> >> I had this complaint from ex-MS types and found that KDE has an extremely
> >> Windows-like network monitor 'tool' which displays the net connections in
> >> the systray using ifconfig/iwconfig/route (knemo). If I switch off the
> >> router I get two little ex'es against the icons and a tooltip popop "Not
> >> Connected": switching the router back on pops up "eth0/1 connected" (or
> >> whatever, its configurable).
> >
> > Ah, this is very helpful. I'd much rather use something like this than
> > try to cobble something together that only does half the job!
>
> This is indeed what KDE does, but I did not suggest that since I
> assumed you were not using KDE (you'd have seen it doing it you
> were!).
>
> For the Gnome world, there is NetworkManager and its applet
> nm-applet. I am pretty sure it can do the same thing (I have not used
> it for a while) but the down side is that it lets your users break
> things by be able o configure their network settings. This is often
> fine, but in an environment where switching off the router is
> problem...
>
> Anyway, it may be worth a look.

OK. It looks like the Gnome version is the one we want. I know most
modern KDE & Gnome stuff is cross-compatible but I didn't really want
to mess about. Also, from further reading, it looks like the manager bit
itself works quietly in the background which would be even better.

We can easily sell the idea that it 'Just Works (tm)' so if they can't
get connected the router must be switched off. We'll pass off the
failure to do this so far as one of us forgetting to switch on
detection Smile

--
Will J G
Back to top
Nix
External


Since: Jul 29, 2004
Posts: 680



PostPosted: Sun Jul 22, 2007 7:28 pm    Post subject: Re: Auto network re-connect [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 21 Jul 2007, Chris F. A. Johnson verbalised:
> Why use cat?
>
> read n < /sys/class/net/eth0/carrier

Hah! Yes, I forgot about read. (I always seem to forget about it except
in while loops... stupid of me.)
Back to top
Folderol
External


Since: Dec 13, 2004
Posts: 118



PostPosted: Sun Jul 22, 2007 9:10 pm    Post subject: Re: Auto network re-connect [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Sun, 22 Jul 2007 19:28:42 +0100
Nix <nix-razor-pit DeleteThis @esperi.org.uk> wrote:

> On 21 Jul 2007, Chris F. A. Johnson verbalised:
> > Why use cat?
> >
> > read n < /sys/class/net/eth0/carrier
>
> Hah! Yes, I forgot about read. (I always seem to forget about it except
> in while loops... stupid of me.)

Actually, I'd used cat because I couldn't seem to work out the syntax
for read from a file :/

--
Will J G
Back to top
Folderol
External


Since: Dec 13, 2004
Posts: 118



PostPosted: Sun Jul 22, 2007 9:12 pm    Post subject: Re: Auto network re-connect [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Sun, 22 Jul 2007 14:33:09 +0100
Nix <nix-razor-pit.DeleteThis@esperi.org.uk> wrote:

> On 21 Jul 2007, folderol.DeleteThis@ukfsn.org told this:
> > On Sat, 21 Jul 2007 18:24:46 +0100
> > Nix <nix-razor-pit.DeleteThis@esperi.org.uk> wrote:
> >> if [[ "x$(cat /sys/class/net/eth0/carrier)" = "x0" ]]; then
> >> sudo /usr/sbin/ethtool -r eth0;
> >> fi
> >>
> >> (significantly faster with many shells, although not bash, and doesn't
> >> collapse with a syntax error if the carrier file doesn't exist or by
> >> some oddity contains something which requires quoting to avoid being
> >> seen as a shell metacharacter.)
> >
> > Thanks. That's very sneaky Smile I can see how the 'x' ensures there is
> > always something valid to compare,
>
> Look at the chapter `Shellology' in the autoconf manual. There's all
> sorts of tricks like this.
>
> > and presumably the round brackets
> > take the place of the back ticks in some way,
>
> $(...) is the POSIX replacement for `...`: unlike backticks, it nests.
>
> (and $((...)) is maths.)
>
> > but how does the double
> > square bracketing help?
>
> On many shells (Solaris ksh, for instance) [[ ]] is a shell builtin where
> [ ] is not, and thus is far faster. (bash, ksh, pdksh, and recent kshs
> have [ ] as a shell builtin too, but I have to write a lot of code that
> runs on lesser platforms, so I've got used to [[ ]]...)

Thanks for all this info. It has become a bit redundant in this
particular case, but I will certainly remember it and follow up with
other scripting ideas.

I get the impression these things are seriously under-used!

--
Will J G
Back to top
Andy Baxter
External


Since: Jun 29, 2007
Posts: 16



PostPosted: Mon Jul 23, 2007 4:53 pm    Post subject: Re: Auto network re-connect [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Tue, 17 Jul 2007 20:09:46 +0100, Folderol wrote:

> Is there a simple way I can get computers that are connected to a
> router to recognise when the router is turned off (possibly giving a
> warning) then automatically connect when it is turned on again?
>

I'm using ubuntu feisty, which has a network manager applet on the taskbar
when you install. This does pretty much what you want I think. see

http://www.gnome.org/projects/NetworkManager/

The only problem I've had with it is that the second time you restart
after a suspend on a laptop, it stops working. But apart from that it's
pretty good.

--
remove 'n-u-l-l' to email me.
Back to top
Ben Bacarisse
External


Since: Jun 10, 2005
Posts: 90



PostPosted: Mon Jul 23, 2007 7:19 pm    Post subject: Re: Auto network re-connect [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Andy Baxter <news5.TakeThisOut@earthsong.null.free-online.co.uk> writes:

> I'm using ubuntu feisty, which has a network manager applet on the taskbar
> when you install. This does pretty much what you want I think. see
>
> http://www.gnome.org/projects/NetworkManager/
>
> The only problem I've had with it is that the second time you restart
> after a suspend on a laptop, it stops working.

Is this a new bug (i.e. in feisty) and do you have a reference? I do
long distance support on a family laptop and there have been reports
of odd behaviour recently after resume (post my upgrade to feisty).

--
Ben.
Back to top
Folderol
External


Since: Dec 13, 2004
Posts: 118



PostPosted: Mon Jul 23, 2007 7:39 pm    Post subject: Re: Auto network re-connect - and the winner is? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Mon, 23 Jul 2007 16:53:43 -0000
Andy Baxter <news5 DeleteThis @earthsong.null.free-online.co.uk> wrote:

> On Tue, 17 Jul 2007 20:09:46 +0100, Folderol wrote:
>
> > Is there a simple way I can get computers that are connected to a
> > router to recognise when the router is turned off (possibly giving a
> > warning) then automatically connect when it is turned on again?
> >
>
> I'm using ubuntu feisty, which has a network manager applet on the taskbar
> when you install. This does pretty much what you want I think. see
>
> http://www.gnome.org/projects/NetworkManager/
>
> The only problem I've had with it is that the second time you restart
> after a suspend on a laptop, it stops working. But apart from that it's
> pretty good.


Ok. We installed network manager today and it seems to work without
any problems. Ours are all desktop machines. None are less that 2 years
old and one is about 5. However an oddity has cropped up.

When I said debian etch, I should have said testing, as it was before
etch was changed to stable. Over the weekend one of the guys did an
etch network install on his home machine and found network manager and
the gnome interface were automagically installed Confused

I predict that the next request/demand will be for printer sharing.
They've never had it before, but someone blabbed so I'm sure it will
soon be absolutely essential that we get it up and running Sad

Rearrange the following into a well known saying!

pants of seat by flying the your

--
Will J G
Back to top
Andy Baxter
External


Since: Jun 29, 2007
Posts: 16



PostPosted: Mon Jul 23, 2007 9:00 pm    Post subject: Re: Auto network re-connect [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Mon, 23 Jul 2007 19:19:26 +0100, Ben Bacarisse wrote:

> Andy Baxter <news5.RemoveThis@earthsong.null.free-online.co.uk> writes:
>
>> I'm using ubuntu feisty, which has a network manager applet on the taskbar
>> when you install. This does pretty much what you want I think. see
>>
>> http://www.gnome.org/projects/NetworkManager/
>>
>> The only problem I've had with it is that the second time you restart
>> after a suspend on a laptop, it stops working.
>
> Is this a new bug (i.e. in feisty) and do you have a reference? I do
> long distance support on a family laptop and there have been reports
> of odd behaviour recently after resume (post my upgrade to feisty).
>

see https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/45696

It looks like a common bug.

--
remove 'n-u-l-l' to email me.
Back to top
Ben Bacarisse
External


Since: Jun 10, 2005
Posts: 90



PostPosted: Mon Jul 23, 2007 11:08 pm    Post subject: Re: Auto network re-connect [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Andy Baxter <news5.RemoveThis@earthsong.null.free-online.co.uk> writes:

> On Mon, 23 Jul 2007 19:19:26 +0100, Ben Bacarisse wrote:
>
>> Andy Baxter <news5.RemoveThis@earthsong.null.free-online.co.uk> writes:
<about NetworkManager>
>>>
>>> The only problem I've had with it is that the second time you restart
>>> after a suspend on a laptop, it stops working.
>>
>> Is this a new bug (i.e. in feisty) and do you have a reference? I do
>> long distance support on a family laptop and there have been reports
>> of odd behaviour recently after resume (post my upgrade to feisty).
>>
> see
> https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/45696

It may well be related. Thank you.

--
Ben.
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> UK All times are: Eastern Time (US & Canada) (change)
Goto page Previous  1, 2
Page 2 of 2

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum