maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   MeeGo / Harmattan (https://talk.maemo.org/forumdisplay.php?f=45)
-   -   Running script when network interface is up (https://talk.maemo.org/showthread.php?t=88976)

sargas 2013-02-03 16:29

Running script when network interface is up
 
Hi all,

i am trying to run this script when network interface is up on my N9:

Code:

#!/bin/sh
date >> /root/data

The script path is:

Code:

/etc/network/if-up.d/50_connect_home
The file /root/data is an existing empty file.


Upon connecting to my wlan, the file /root/data is still empty, which suggests the script does not run.

Any pointers?

Thanks,
sargas.

ffha 2013-02-03 16:35

Re: Running script when network interface is up
 
Forgive me if I'm wrong, for I don't have a N9 myself, but doesn't Aegis prevent modification of files owned by root, even by root itself?

Try to append the data to a file in your home folder.

sargas 2013-02-03 18:26

Re: Running script when network interface is up
 
Quote:

Originally Posted by ffha (Post 1320457)
Forgive me if I'm wrong, for I don't have a N9 myself, but doesn't Aegis prevent modification of files owned by root, even by root itself?

I guess not since i can execute the script manually, as root, and the file gets modified.

Quote:

Originally Posted by ffha (Post 1320457)
Try to append the data to a file in your home folder.

Trying with /home/user/data, like sugested, has no effect either.
I think there is something more to be done than just putting the script in /etc/network/if-up.d/ but i can't figure it out.

Wikiwide 2013-02-03 22:33

Re: Running script when network interface is up
 
Quick reply...
Look up file "/etc/network/interfaces". Besides lines "address ...", "netmask ....", "gateway ...", there can also be lines "up ...." and "down ..." - to run scripts when a connection starts and stops.
Best wishes.

anthonie 2013-02-03 22:57

Re: Running script when network interface is up
 
So, what does your check for ifup look like? The condition itself, if you like, not what you do if and when the condition is met.

Wikiwide 2013-02-04 03:56

Re: Running script when network interface is up
 
Quick reply...
Contents of file "/etc/network/interaces":
Code:

auto usb0
iface usb0 inet static
        address 192.168.2.15
        netmask 255.255.255.0
        gateway 192.168.2.14
        up /usr/lib/sdk-connectivity-tool/usbdhcpd.sh 192.168.2.14
        down /usr/lib/sdk-connectivity-tool/usbdhcpd.sh stop

With appropriate setup on PC, it allows to give Internet from PC to Harmattan device.
Best wishes.

ii343hbka 2013-02-04 04:37

Re: Running script when network interface is up
 
try to set a execute bit
Code:

sudo chmod +x path_to_script
also you can try to use full path for echo instead of it's binary name
or jsut set up a PATH variable
Code:

#!/bin/sh
PATH=$PATH:/bin


peterleinchen 2013-02-04 09:43

Re: Running script when network interface is up
 
Quote:

Originally Posted by ii343hbka (Post 1320612)
try to set a execute bit
Code:

sudo chmod +x path_to_script

This could be the cause here.

sargas 2013-02-04 18:25

Re: Running script when network interface is up
 
Quote:

Originally Posted by Wikiwide (Post 1320558)
Quick reply...
Look up file "/etc/network/interfaces". Besides lines "address ...", "netmask ....", "gateway ...", there can also be lines "up ...." and "down ..." - to run scripts when a connection starts and stops.
Best wishes.

Thanks, but still not working. I have tried to add:
Code:

 
auto wlan0
        iface wlan0 inet dhcp
        up /etc/network/if-up.d/50_connect_home

to /etc/network/interfaces

Also tried just one line at end of file:
Code:

up /etc/network/if-up.d/50_connect_home
The script does not run.

Edit: fixed code tags.

sargas 2013-02-04 18:27

Re: Running script when network interface is up
 
Quote:

Originally Posted by peterleinchen (Post 1320663)
This could be the cause here.

Thanks, but first thing i've tried was to set the script executable.


All times are GMT. The time now is 00:20.

vBulletin® Version 3.8.8