Running a python program in pfsense
-
Hi, new to pfsense and networking stuff. I'm trying to run a python script but just testing pfsense out by running a normal program first.
So, I went into the shell
- Made a program called try.py using "touch try.py"
- Edited the program using vi and putting print("hi")
- Tried to run it using "./try.py"
but it doesn't work. I'm using 2.4.4 and it should have python 2.7 installed right?
it gives the error of "./try.py: 1: Syntax error: word unexpected (expecting ")")
Am I doing something wrong?
-
python try.py
Look up what a
shebang
is. -
On pfSense 2.4.4, python 2.7 is available as
python2.7
. So yourtry.py
could run one of a couple ways:- Run the script using the correct binary:
python2.7 try.py
- Edit
try.py
, change the first line to reflect the correct python binary, which will allow it to run with./try.py
#!/usr/bin/env python2.7
- Make a symlink so you can invoke python 2.7 as
python
ln -s /usr/local/bin/python2.7 /usr/local/bin/python
Note that in the future when python versions change, you would need to update whichever method you choose to point to the new binary, such as
python3.6
. - Run the script using the correct binary:
Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.