maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Maemo 5 / Fremantle (https://talk.maemo.org/forumdisplay.php?f=40)
-   -   Run script on connection to specific network (https://talk.maemo.org/showthread.php?t=39844)

peterjb31 2010-01-09 11:56

Run script on connection to specific network
 
Hi all

I've tried searching for this but haven't found anything relevant as of yet.

What I want to do is get the N900 to run a script if it's connected to a specific network (specifically a backup script).

Alternatively does anyone know of a way of detecting what network the N900 is connected to using either Python or a command line command?

Many thanks for any help you can offer.

Matan 2010-01-09 12:23

Re: Run script on connection to specific network
 
dbus-scripts allows for running a script upon connection event. For example the following line in the config file /etc/dbus-scripts.d/orange runs the script /usr/local/bin/db-orange whenever a connection called orange of type DUMMY is established.

/usr/local/bin/db-orange * * com.nokia.icd status_changed orange DUMMY CONNECTED

Note that if you use connection generated by the GUI, you need to use their ID, rather than name.

For the second question, run the commands:

dbus-send --print-reply --system --dest=com.nokia.icd /com/nokia/icd com.nokia.icd.get_statistics
and
dbus-send --print-reply --system --dest=com.nokia.icd /com/nokia/icd com.nokia.icd.get_state

peterjb31 2010-01-09 12:40

Re: Run script on connection to specific network
 
Hi Matan

When I try running the dbus commands I get a series of unintelligible strings and ints, is there any way of making it tell me the name of the connection in a more human readable form. For example if I connect to a network with the ssid wifi can I get it to say when it's connected to wifi?

Thanks for any help.

Peter

Matan 2010-01-09 12:47

Re: Run script on connection to specific network
 
The first string in get_statistics gives you the id of the string. you need to look at the gconf database to convert it to a name.

In python you need to do something like:

self.conns = gconf_client.all_dirs("/system/osso/connectivity/IAP")
for item in self.conns:
name=gconf_client.get_string(item+"/name")

MiNe 2010-01-15 17:58

Re: Run script on connection to specific network
 
Hi,
I also want to run a shell command when my mobile connects to a specific wifi connection but I can't find the directory "/etc/dbus-scripts.d/". I just see "/etc/dbus-1/". Is there something different with the new firmware?
Code:

Nokia-N900-42-11:/# uname -a
Linux Nokia-N900-42-11 2.6.28-omap1 #1 PREEMPT Thu Dec 17 09:40:52 EET 2009 armv7l unknown

I just want to run the command "vpnc vpnc" when the phone connects to the wifi "tug".

Please help me to get it work.

newpipe

rambo 2010-01-15 19:59

Re: Run script on connection to specific network
 
/etc/network/up.d is also a place good place to run shell scripts (you need to check the connection from the scripts however). Sorry that I can't remember offhand exact commands for you.

niv 2010-03-23 23:12

Re: Run script on connection to specific network
 
Quote:

Originally Posted by Matan (Post 460957)
The first string in get_statistics gives you the id of the string. you need to look at the gconf database to convert it to a name.

In python you need to do something like:

self.conns = gconf_client.all_dirs("/system/osso/connectivity/IAP")
for item in self.conns:
name=gconf_client.get_string(item+"/name")

I must have misunderstand you, as pasting these in python - doesnt work.
I used this:
Code:

gconftool -R  /system/osso/connectivity/IAP |more
and looked for the GPRS section (first in my case)
by ID , do you mean what I marked bold?
Quote:

last_used_type = GPRS
flightmode_wlan = false
wlan_tx_power = 8
last_used_attrs = 83886080
last_used_network = Internet 3G
/system/osso/connectivity/IAP/36d13d8b-5baf-49af-8a3c-508c3c2a558f:
wlan_security = NONE

Matan 2010-03-23 23:26

Re: Run script on connection to specific network
 
This is not the GPRS section. Try to understand the output from gconftool by considering the indentation.

niv 2010-03-25 11:11

Re: Run script on connection to specific network
 
One remark: running /etc/init.d/dbus-scripts reload , doesnt work here

http://talk.maemo.org/showpost.php?p=572440&postcount=2


All times are GMT. The time now is 05:53.

vBulletin® Version 3.8.8