OPNsense Forum

Archive => 19.1 Legacy Series => Topic started by: AveryFreeman on February 20, 2019, 12:11:26 am

Title: Run python script?
Post by: AveryFreeman on February 20, 2019, 12:11:26 am
Hey,

new to OPNSense / hardened FreeBSD

Just installed OPNSense 19.1, trying to re-create the experience I had on pfsense 2.4.4

Used to like running speedtest-cli: https://github.com/sivel/speedtest-cli

Python appears to be installed:

Code: [Select]
# pkg install python27
Updating OPNsense repository catalogue...
OPNsense repository is up to date.
All repositories are up to date.
Checking integrity... done (0 conflicting)
The most recent version of packages are already installed

Script says:

Code: [Select]
# ./speedtest.py
env: python: No such file or directory

But can't find or run (?):

Code: [Select]
# find / -name py*
find: No match.

# which python
python: Command not found.

I found the executable in `/usr/local/bin` but is this normal behavior for `find` and `which` in Hardened FreeBSD?  I use these commands a lot.

Thanks!

Title: Re: Run python script?
Post by: jinn on February 20, 2019, 09:25:19 am
usr/local/bin/python2.7 speedtest.py
Title: Re: Run python script?
Post by: GaardenZwerch on February 20, 2019, 03:17:34 pm
Code: [Select]
# find / -name py*
find: No match.

# which python
python: Command not found.


Regards,
Frank
Title: Re: Run python script?
Post by: AveryFreeman on February 20, 2019, 07:36:46 pm
But I guess my question is, why does find not work with wildcards?  It does on every other posix platform I've tried...
Title: Re: Run python script?
Post by: franco on February 20, 2019, 08:18:46 pm
Err, you’re globing in the current path, not passing it to find.

Freebsd is python-version agnostic, it needs the version to find the binary:

https://github.com/opnsense/core/blob/eb95e8f53e56e25ce8f0898ee6936d8201bd9a29/src/opnsense/scripts/suricata/dropAlertLog.py#L1

The downside is „python“ doesn’t exist, the upside is you can install all python versions side by side.


Cheers,
Franco
Title: Re: Run python script?
Post by: fabian on February 20, 2019, 08:55:16 pm
The problem is that it is not FreeBSD specific. python is any python interpreter and for example it is Python 2.7 on Debian / Ubuntu etc., but 3.x on Arch Linux which causes errors too, so this scripts should always mention at least the major version.