Networking Forums

Networking Forums > Computer Networking > Linux Networking > Execute a script when a network-interface come up?

Reply
Thread Tools Display Modes

Execute a script when a network-interface come up?

 
 
Lasse Madsen
Guest
Posts: n/a

 
      12-08-2005, 09:09 AM
Hey

I have tried to figure out, where I should place a file, which should be
executed when a network-interface come up
I have tried /etc/network/if-up.d, but it didn't help
 
Reply With Quote
 
 
 
 
chris-usenet@roaima.co.uk
Guest
Posts: n/a

 
      12-08-2005, 01:06 PM
Lasse Madsen <(E-Mail Removed)> wrote:
> I have tried to figure out, where I should place a file, which should be
> executed when a network-interface come up
> I have tried /etc/network/if-up.d, but it didn't help


man interfaces:

"There exists for each of the above mentioned options a directory
/etc/network/if-<option>.d/ the scripts in which are run (with
no arguments) using run-parts(8) after the option itself has been
processed.

From context, I'd suggest that <option> can be one of the following
keywords: pre-up, up, post-up, down, pre-down, post-down.


man run-parts:

"If the --lsbsysinit option is not given then the names must consist
entirely of upper and lower case letters, digits, underscores,
and hyphens.

"Files are run in the lexical sort order of their names unless
the --reverse option is given, in which case they are run in the
opposite order.


If you've already worked through these two man pages then you'll need
to give some more information, such as file names, what the program is
trying to do, and how you know "it didn't help"

Chris
 
Reply With Quote
 
Bit Twister
Guest
Posts: n/a

 
      12-08-2005, 01:17 PM
On Thu, 08 Dec 2005 11:09:17 +0100, Lasse Madsen wrote:
> Hey
>

Please read http://www.catb.org/~esr/faqs/smart-questions.html
Over 200+ linux distributions out there.
Always provide distribution, release, and if Mandriva/drake, RCn,
official, cooker, when posting questions.
It could help you get better answers.

> I have tried to figure out, where I should place a file, which should be
> executed when a network-interface come up
> I have tried /etc/network/if-up.d, but it didn't help



Are you sure. Create another script, say a_test, with the following

env > /tmp/a_test.env
exit 0


Then do a
chmod +x a_test

Now bounce the network connection.
On Redhat and Mandriva/drake the command is

service network restart

Now check if a_test ran with
cat /tmp/a_test.env

On Mandriva/drake directory is /etc/sysconfig/network-scripts/ifup.d/
 
Reply With Quote
 
Robert Nichols
Guest
Posts: n/a

 
      12-08-2005, 04:18 PM
In article <4398064d$0$15794$(E-Mail Removed)>,
Lasse Madsen <(E-Mail Removed)> wrote:
:Hey
:
:I have tried to figure out, where I should place a file, which should be
:executed when a network-interface come up
:I have tried /etc/network/if-up.d, but it didn't help

What Linux distribution? On Red-Hat-like systems, you put the script in
/sbin and name it "ifup-local". It gets called from scripts in
/etc/sysconfig/network-scripts:

/sbin/ifup-local ${DEVICE}

I actually have mine in /usr/local/sbin with just a symlink in /sbin.

--
Bob Nichols AT comcast.net I am "RNichols42"
 
Reply With Quote
 
Lasse Madsen
Guest
Posts: n/a

 
      12-08-2005, 05:23 PM
chris-(E-Mail Removed) wrote:
> Lasse Madsen <(E-Mail Removed)> wrote:
>
>>I have tried to figure out, where I should place a file, which should be
>>executed when a network-interface come up
>>I have tried /etc/network/if-up.d, but it didn't help

>
>
> man interfaces:
>
> "There exists for each of the above mentioned options a directory
> /etc/network/if-<option>.d/ the scripts in which are run (with
> no arguments) using run-parts(8) after the option itself has been
> processed.
>
> From context, I'd suggest that <option> can be one of the following
> keywords: pre-up, up, post-up, down, pre-down, post-down.
>
>
> man run-parts:
>
> "If the --lsbsysinit option is not given then the names must consist
> entirely of upper and lower case letters, digits, underscores,
> and hyphens.
>
> "Files are run in the lexical sort order of their names unless
> the --reverse option is given, in which case they are run in the
> opposite order.
>
>
> If you've already worked through these two man pages then you'll need
> to give some more information, such as file names, what the program is
> trying to do, and how you know "it didn't help"
>
> Chris


The filename is net.sh
It's a script, I have programmed myself
The script should try to get an url, but there should be no output, so
the script looks like:
wget --output-file=/dev/null <url to my server> > /dev/null

On my server the page it should visit should take the ip address from
the laptop, so it could be set up to apache like a virtualhost
 
Reply With Quote
 
Lasse Madsen
Guest
Posts: n/a

 
      12-08-2005, 05:27 PM
Robert Nichols wrote:
> In article <4398064d$0$15794$(E-Mail Removed)>,
> Lasse Madsen <(E-Mail Removed)> wrote:
> :Hey
> :
> :I have tried to figure out, where I should place a file, which should be
> :executed when a network-interface come up
> :I have tried /etc/network/if-up.d, but it didn't help
>
> What Linux distribution? On Red-Hat-like systems, you put the script in
> /sbin and name it "ifup-local". It gets called from scripts in
> /etc/sysconfig/network-scripts:
>
> /sbin/ifup-local ${DEVICE}
>
> I actually have mine in /usr/local/sbin with just a symlink in /sbin.
>


I'm using Kubuntu, so I don't know if it can help me :s
 
Reply With Quote
 
Lasse Madsen
Guest
Posts: n/a

 
      12-08-2005, 05:31 PM
Bit Twister wrote:
> On Thu, 08 Dec 2005 11:09:17 +0100, Lasse Madsen wrote:
>
>>Hey
>>

>
> Please read http://www.catb.org/~esr/faqs/smart-questions.html
> Over 200+ linux distributions out there.
> Always provide distribution, release, and if Mandriva/drake, RCn,
> official, cooker, when posting questions.
> It could help you get better answers.
>
>
>>I have tried to figure out, where I should place a file, which should be
>>executed when a network-interface come up
>>I have tried /etc/network/if-up.d, but it didn't help

>
>
>
> Are you sure. Create another script, say a_test, with the following
>
> env > /tmp/a_test.env
> exit 0
>
>
> Then do a
> chmod +x a_test
>
> Now bounce the network connection.
> On Redhat and Mandriva/drake the command is
>
> service network restart
>
> Now check if a_test ran with
> cat /tmp/a_test.env
>
> On Mandriva/drake directory is /etc/sysconfig/network-scripts/ifup.d/


Does it also work on Kubuntu :s
I haven't found a newsreader on Kubuntu, so I'm using Windows, when I'm
reading newsmails
 
Reply With Quote
 
Bit Twister
Guest
Posts: n/a

 
      12-08-2005, 07:02 PM
On Thu, 08 Dec 2005 19:31:12 +0100, Lasse Madsen wrote:
>
> Does it also work on Kubuntu :s


You are the one to tell us if it works or not.

> I haven't found a newsreader on Kubuntu, so I'm using Windows, when I'm
> reading newsmails


slrn is a good usenet text based reader.
 
Reply With Quote
 
Lasse Madsen
Guest
Posts: n/a

 
      12-08-2005, 07:25 PM
Bit Twister wrote:
> On Thu, 08 Dec 2005 19:31:12 +0100, Lasse Madsen wrote:
>
>>Does it also work on Kubuntu :s

>
>
> You are the one to tell us if it works or not.


Yes, I will do that after some time

>>I haven't found a newsreader on Kubuntu, so I'm using Windows, when I'm
>>reading newsmails

>
>
> slrn is a good usenet text based reader.


I had think about Mozilla Thunderbird, but I can't set my emailadress up
there :'(
 
Reply With Quote
 
chris dewbery
Guest
Posts: n/a

 
      12-08-2005, 09:59 PM
Lasse Madsen wrote:
> Hey
>
> I have tried to figure out, where I should place a file, which should be
> executed when a network-interface come up
> I have tried /etc/network/if-up.d, but it didn't help


I believe the script has to have numbers as the first two characters and
be set to executable.

i.e

chmod +x 01myscript

 
Reply With Quote
 
 
 
Reply

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Execute second command only if first fails/succeeds? Matthew Lincoln Linux Networking 3 06-30-2008 01:10 AM
Triggering script when network interface comes up Kenneth Porter Windows Networking 1 04-20-2007 10:54 AM
I am in need of a netsh script that will disable the "Local Area Connection" interface then re-enable that same interface. Spin Windows Networking 3 11-03-2005 12:58 AM
.net execute remotely Tom Windows Networking 0 06-30-2005 04:43 PM
Logon scripts wont execute CJ Coll Windows Networking 1 12-19-2003 04:48 PM



1 2 3 4 5 6 7 8 9 10 11