Run python script?

Started by AveryFreeman, February 20, 2019, 12:11:26 AM

Previous topic - Next topic
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:


# 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:


# ./speedtest.py
env: python: No such file or directory


But can't find or run (?):


# 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!



# find / -name py*
find: No match.

# which python
python: Command not found.



  • OPNSense's shell has tab completion, so entering
    py<tab><tab> shows you all executables starting with py
  • your find command does not work because of how wildcard expansion works in the shell: either find / -name "py*" or find / -name py\* will do what you intended

Regards,
Frank

But I guess my question is, why does find not work with wildcards?  It does on every other posix platform I've tried...

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

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.