Re: [OpenWrt-Users] Pip command found error even though pip is installed

2018-04-18 Thread Lars Kruse
Hello Phani,


Am Wed, 18 Apr 2018 18:14:28 -0500
schrieb Phani Siriki :

> root@OpenWrt:~# ldd /mnt/usb/usr/bin/pip
> -ash: /mnt/usb/usr/bin/pip: not found
> root@OpenWrt:~# ls -l /mnt/usb/usr/bin/pip
> -rwxr-xr-x1 root root   284 Sep  9  2015 /mnt/usb/usr/bin/pip

another possible cause for the above error message could be a wrong shebang
(the first line in a script indicating its interpreter).
Usually this would expose a different error message - but maybe these
messages are simplified in busybox.

If the shebang is fine, you will need to find another reason, why this file
could be non-executable.

btw.: if you really need a full Python environment (incl. third-party modules),
then maybe an embedded environment like OpenWrt could turn out to complicate
this task a bit too much. Could micropython be an option instead? Or a
distribution that is not targeted at embedded devices?

Cheers,
Lars
___
openwrt-users mailing list
openwrt-users@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-users


Re: [OpenWrt-Users] How to execute python script in rpc shell script

2018-04-06 Thread Lars Kruse
Hello Phani,


thanks to Damiano's summary of proper usage of the external installation root,
it should now be a solvable riddle ...


Am Fri, 6 Apr 2018 20:25:08 -0500
schrieb Phani Siriki :

> [..]
> json_get_var $interface "interface"
> json_get_var $tx_power "tx_power"
> 
> /usr/bin/python
> /root/change_wifi_tx_power.py  $interface $tx_power > /root/file 2>&1

You need to make sure, that the environment of this python process contains the
environment variables, that Damiano mentioned (specifically LD_LIBRARY_PATH).
Thus you need to source the /etc/profile file before the python-call above.

For your understanding: every process receives an "environment" (set of
textual variables with values) from its parent when it is started.
In your case, then shell script "foo" creates the python process. Thus the
shell script needs to prepare the environment, that the python process should
use. The set of variables that should be inherited by the child process, can be
configured via "export" (in a shell).
Thus it is not relevant, how your shell is configured, when you are interacting
with the script via ubus calls (e.g. "ubus call foo ..."). The only relevant
environment is the one, that is passed from the "foo" shell script to the
python process.

Cheers,
Lars
___
openwrt-users mailing list
openwrt-users@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-users


Re: [OpenWrt-Users] How to execute python script in rpc shell script

2018-04-06 Thread Lars Kruse
Hello Phani,


let us step back to this issue ...


Am Wed, 4 Apr 2018 15:02:13 -0500
schrieb Phani Siriki :

> I am able to execute python script after creating below soft links.
> 
>  ln -s /mnt/usb/usr/lib/libz.so.1 /usr/lib/libz.so.1
>  ln -s /mnt/usb/lib/libpthread.so.0 /usr/lib/libpthread.so.0
>  ln -s /mnt/usb/usr/lib/libpython2.7.so.1.0  /usr/lib/libpython2.7.so.1.0

The fact that you need to create symlinks manually feels wrong to me.

I am not used to installing packages to non-root locations, thus I cannot tell,
whether this is normal or an indication of a problem. Can you tell?

I would recommend to verify, that your setup in general is correctly configured.
Did you follow a reasonable documentation? Which one?
Did you deviate? Did you notice problems, that you had to work around?

Maybe someone else has an idea what is going wrong here?

Cheers,
Lars
___
openwrt-users mailing list
openwrt-users@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-users


Re: [OpenWrt-Users] How to execute python script in rpc shell script

2018-04-05 Thread Lars Kruse
Hello Phani,


Am Wed, 4 Apr 2018 15:02:13 -0500
schrieb Phani Siriki :

> I am able to import the module through normal execution. However it is
> not working in rpcd shell script. Could you please give me some
> inputs?

you could try to compare the search path under both conditions.

Probably the following would be sufficient?

 open("/tmp/pythonpath.out", "w").write("\n".join(sys.path))

(to be placed before the critical import statement)


Cheers,
Lars
___
openwrt-users mailing list
openwrt-users@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-users


Re: [OpenWrt-Users] How to execute python script in rpc shell script

2018-02-17 Thread Lars Kruse
Hello Phani,


Am Sat, 17 Feb 2018 12:22:02 -0600
schrieb Phani Siriki :

> root@OpenWrt:~# cat file-name
> /usr/bin/python: can't load library 'libpython2.7.so.1.0'

so this discussion revolved around the same topic as your other thread
("Pip command found error even though pip is installed").
Thus you will need to fix your python installation.

The usual steps:
* remove and install again
* find out, how your setup differs from the setup of others

Cheers,
Lars
___
openwrt-users mailing list
openwrt-users@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-users


Re: [OpenWrt-Users] How to execute python script in rpc shell script

2018-02-15 Thread Lars Kruse
Hello Phani,


Am Thu, 15 Feb 2018 09:21:09 -0600
schrieb Phani Siriki :

> I tried as suggested, but it didn't work :(

Just in case you are running out of ideas:
did you try the suggestions that I put down in my first response to this thread
(Wed, 14 Feb 2018 21:56:08 +0100)?
What did you discover along this path?

Cheers,
Lars 
___
openwrt-users mailing list
openwrt-users@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-users


Re: [OpenWrt-Users] Pip command found error even though pip is installed

2018-02-14 Thread Lars Kruse
Hello Phani,


Am Wed, 14 Feb 2018 15:00:34 -0600
schrieb Phani Siriki :

> root@Mesh-30:~# python
> -ash: python: not found

I guess, this means that one of the libraries that the python binary is linked
against, is missing.
Maybe run "ldd /usr/bin/python" and check if all referenced libraries exist.

Cheers,
Lars
___
openwrt-users mailing list
openwrt-users@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-users


Re: [OpenWrt-Users] How to execute python script in rpc shell script

2018-02-14 Thread Lars Kruse
Hello Saverio,


Am Wed, 14 Feb 2018 21:43:46 +0100
schrieb Saverio Proto :

> Add something like:
> 
> #!/usr/bin/env python
> 
> at the first line of your python script

in this specific case it is not relevant, since he is calling the interpreter
with the script filename as an argument ("python /root/hello.py"). But it would
be necessary if he just called the script without specifying the interpreter
(e.g. "/root/hello.py").

Anyway: a shebang is surely always a good thing for scripts.

Cheers,
Lars
___
openwrt-users mailing list
openwrt-users@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-users


Re: [OpenWrt-Users] How to execute python script in rpc shell script

2018-02-14 Thread Lars Kruse
Hello Phani,


Am Wed, 14 Feb 2018 12:11:16 -0600
schrieb Phani Siriki :

> I want to execute my custom python scripts in rpc shell script. However,
> they are not executed. Could someone help me on this?

I am not familiar with the details of the rpcd insterface you are using - but
probably your problem is generic, anyway.

You should probably walk along the usual debugging path:
- try to find out, why no messages from stderr are printed (failure to call the
  python script or failure within the python script) - maybe redirect stderr
  to stdout in your call of the python interpreter
- maybe start the python script with some "print" statements (instead of "call")
  in order to find out, if the python script is running at all
- if everything fails: use strace or similar tools in order to find out, if the
  python script file is accessed at all
- ...

Happy hunting!
Lars


PS: please do not cross post (here: at least openwrt-user and openwrt-devel
mailinglists) - see [1]

[1] http://catb.org/~esr/faqs/smart-questions.html#forum
___
openwrt-users mailing list
openwrt-users@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-users


Re: [OpenWrt-Users] Pip command found error even though pip is installed

2018-02-06 Thread Lars Kruse
Hello Phani,


Am Tue, 6 Feb 2018 10:14:46 -0600
schrieb Phani Siriki :

> I am using chaos calmer build and installed python on usb. When i tried to
> install python-pip, it gives me below error. However, pip is installed. But
> when I tried to run it, it says command not found. Could some one help me
> on this?

did you take a look at the list of files belonging to the "python-pip"
package?

 opkg files python-pip

I could imagine, that the package contains only the python module - and
maybe not a script in /usr/bin.

Maybe "python -m pip ..." works?
(just wild guessing)

Lars
___
openwrt-users mailing list
openwrt-users@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-users


Re: [OpenWrt-Users] Multi-point VPN on OpenWRT

2017-08-25 Thread Lars Kruse
Hello Lucas,


Am Fri, 25 Aug 2017 11:05:02 -0300
schrieb Lucas Dutra :

> I'm studying this option and it seems to be a nice solution. Anyone 
> knows another solution for dynamic tunneling multi-point VPN's hub-to-spoke
> based?

based on your description, I could imagine that tinc or openvpn could be
suitable for you. Just adding more data points to your research list :)

I cannot judge, how comfortable you feel with routing and VPN, but I guess,
that IPSec could be a bit tricky if you are just starting with this topic.

Cheers,
Lars
___
openwrt-users mailing list
openwrt-users@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-users


Re: [OpenWrt-Users] su utility in OpenWRT "White Russian" release

2017-01-28 Thread Lars Kruse
Hello Martin,


Am Sat, 28 Jan 2017 01:21:41 +0200
schrieb Martin T :

> [..]
> Or maybe there is some smarter way?

could a simple "ssh root@localhost" solve your problem?
Maybe add an alias, if you really insist on typing "su"?

Cheers,
Lars
___
openwrt-users mailing list
openwrt-users@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-users


Re: [OpenWrt-Users] Installing packages in OpenWrt

2016-11-15 Thread Lars Kruse
Hi,


Am Mon, 14 Nov 2016 18:10:56 +
schrieb James Allsopp :

> [..]
> root@OpenWrt:~# df -h /

maybe the filesystem has no free inodes left.
Sadly "df -i" is not supported by the default busybox configuration in openwrt.
You can take a look at the filesystem from the outside:
 tune2fs -l firmware.img
Look for "Free inodes".

In this case you need to recreate the filesystem, since the inode count is only
configurable during filesystem creation.

Cheers,
Lars
___
openwrt-users mailing list
openwrt-users@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-users


Re: [OpenWrt-Users] ifdown does not disable wifi interface

2016-07-05 Thread Lars Kruse
Hello kuniu,


Am Tue, 5 Jul 2016 23:31:36 +0100
schrieb koniu <gkusni...@gmail.com>:

> On Tue, 5 Jul 2016 13:22:40 +0200
> Lars Kruse <li...@sumpfralle.de> wrote:
> > "wifi down" would be an alternative approach for this problem
> > (shutting down all wifi interfaces). But I do not want to interfere
> > with the other wifi interfaces - thus this would not be an option for
> > me.
> > 
> > Can someone recommend a way to disable specific wifi interfaces
> > (ideally based on the name of its logical network interface)?  
> 
> Not 100% sure what you mean by "logical network interface" but maybe
> you're looking for:
> 
>   # wifi down radio0

This is a good start.
Sadly it is not as specific as I would prefer (there are going to be multiple
wireless interfaces using the same radio), but it is better than my current
approach.



> [..]
> You could also do:
> 
>   # uci set wireless.@wifi-iface[0].disabled='1'
>   # wifi reload

My original plan was to disable the "auto" flag of the interface and control
its state via "ifup" and "ifdown" (based on events).
This would allow human users to override the automatic behaviour via the above
"disabled" flag of the wireless interface, if necessary. But maybe this is not
too important.


> If by interface you mean eg "lan" (as in iface names
> in /etc/config/network) then you need to get the mapping from "lan" to
> "radio0" using (for example) something like this:
> 
>   # uci show wireless.$(uci show wireless | grep lan | cut -d. -f2) |\
> grep device |cut -d= -f2 to get 
> 
> You can of course get the logical-network-iface > logical-wifi-iface
> mapping in other ways (ubus, libiwinfo-lua, ...)

I was hoping to learn an approach that would free me from retrieving the
corresponding wireless interface(s) on my own. A simple counterpart of "ifup"
would have been really nice.

Anway: thank you for your time and your hints. I will follow your advice.

Cheers,
Lars
___
openwrt-users mailing list
openwrt-users@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-users


[OpenWrt-Users] ifdown does not disable wifi interface

2016-07-05 Thread Lars Kruse
Hello,

I would like to disable an interface (e.g. the preconfigured "wifi") interface
in a script.
I expected that "ifdown wifi" would accomplish this (or "ifdown lan" -
depending on the interface name, as seen in "Administration -> Network ->
Interfaces").

But it seems that this only removes the IP configuration of the interface. The
physical wifi interface (here: wlan0) still exposes the configured SSID.

"wifi down" would be an alternative approach for this problem (shutting down
all wifi interfaces). But I do not want to interfere with the other wifi
interfaces - thus this would not be an option for me.

Can someone recommend a way to disable specific wifi interfaces (ideally based
on the name of its logical network interface)?

Thank you for your time!

Cheers,
Lars
___
openwrt-users mailing list
openwrt-users@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-users