# Run Python Script -



## monchito (Mar 21, 2017)

Hi all, i'm brand new on FreeBSD, i want to run a python script for pfsense firewall running on FreeBSD (FreeBSD 10.3-RELEASE-p9)

this is the script
https://github.com/edgauthier/pfsense-backup

I already installed beautifulsoup4 (py27-beautifulsoup-4.4.1)

So, when i make this as root
`. pfsense-backup.py`
get this:
`/usr/local/bin/.: Permission denied.`


What i tried:

`Chmod +x pfsense-backup.py`
`Chmod 775 pfsense-backup.py`
those are the permissions:
`-rwxrwxrwx  1 root  wheel  6278 Mar 21 16:00 pfsense-backup.py`
Changes on the script: 
`#!/usr/bin/env python2`
to
`#!/usr/local/bin python2`

What i doing wrong?

Thanks!
Monchito[/code]


----------



## tobik@ (Mar 21, 2017)

monchito said:


> So, when i make this as root
> . pfsense-backup.py
> get this:
> /usr/local/bin/.: Permission denied.


If the script is already in /usr/local/bin just use `pfsense-backup.py`

Why do you think you need the dot?

EDIT: Hold on. This is wrong too:


monchito said:


> Changes on the script:
> #!/usr/bin/env python2
> to
> #!/usr/local/bin python2


You could have left the line as is. If you change it, it should be #!/usr/local/bin/python2


----------



## monchito (Mar 21, 2017)

Hi tobik, i don't know i thought i should.

Now, i get this:
`pfsense-backup.py
pfsense-backup.py: Command not found.`

Thanks for the help.


----------



## tobik@ (Mar 21, 2017)

Try with `./pfsense-backup.py`


----------



## monchito (Mar 21, 2017)

Hi, back again to Permission denied.

`/usr/local/bin: ./pfsense-backup.py
./pfsense-backup.py: Permission denied.`

`/usr/local/bin: ls -ld
drwxr-xr-x  2 root  wheel  6144 Mar 21 18:21`

thanks


----------



## tobik@ (Mar 21, 2017)

Have you corrected the #! line in pfsense-backup.py e.g. to #!/usr/local/bin/python2 ?


----------



## monchito (Mar 22, 2017)

Hi, yes. Reading this : https://docs.python.org/2/using/unix.html y change the Shebang:

old line
`#!/usr/bin/env python2`

changed for this:
`#!/usr/local/bin python2`


----------



## Eric A. Borisch (Mar 22, 2017)

monchito said:


> Hi, yes. Reading this : https://docs.python.org/2/using/unix.html y change the Shebang:
> 
> old line
> `#!/usr/bin/env python2`
> ...



Either of `#!/usr/bin/env python2` or `#!/usr/local/bin[color=red]/[/color]python2` (note the /, not ' ') should work, although the first version only works if python2 is found in $PATH.

The first works because it is the env(1) tool that is actually being executed, with an argument of 'python2' as the utility to execute.


----------



## SirDice (Mar 22, 2017)

PC-BSD, FreeNAS, NAS4Free, and all other FreeBSD Derivatives


----------



## monchito (Mar 23, 2017)

Eric A. Borisch said:


> Either of `#!/usr/bin/env python2` or `#!/usr/local/bin[COLOR=red]/[/COLOR]python2` (note the /, not ' ') should work, although the first version only works if python2 is found in $PATH.
> 
> The first works because it is the env(1) tool that is actually being executed, with an argument of 'python2' as the utility to execute.



Ok, thanks, is good to know. Not work neither `#!/usr/bin/env python2` or `#!/usr/local/bin/python2`



SirDice said:


> PC-BSD, FreeNAS, NAS4Free, and all other FreeBSD Derivatives



Thanks, i'll ask in pfsense forum.


----------

