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

    1. Made a program called using "touch"
    2. Edited the program using vi and putting print("hi")
    3. Tried to run it using "./"
      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 "./ 1: Syntax error: word unexpected (expecting ")")

    Am I doing something wrong?

  • LAYER 8 Netgate


    Look up what a shebang is.

  • Rebel Alliance Developer Netgate

    On pfSense 2.4.4, python 2.7 is available as python2.7. So your could run one of a couple ways:

    1. Run the script using the correct binary:
    2. Edit, change the first line to reflect the correct python binary, which will allow it to run with ./
      #!/usr/bin/env python2.7
    3. 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.

Log in to reply