Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 1225

Python • script won't execute but permissions look OK

$
0
0
I have a Bookworm 64 bit lite Pi

I have a python3 script at /opt/wibble/foobar that works, and runs fine if I do 'cd /opt/wibble' and then 'python3 ./foobar' or './foobar'. Note that the script is owned by dsf:dsf, though I am ian:ian:

Code:

ian@Delta:~ $ cd /opt/wibbleian@Delta:/opt/wibble $ ls -ltotal 4-rwxrwxr-x 1 dsf dsf 36 Apr 25 18:36 foobarian@Delta:/opt/wibble $ ./foobarhelloian@Delta:/opt/wibble $
However, if I copy the script to a little further down the tree, it no longer works:

Code:

ian@Delta:/opt/wibble $ sudo cp foobar ../dsf/plugins/FilamentLoadCell/dsfian@Delta:/opt/wibble $ cd ../dsf/plugins/FilamentLoadCell/dsfian@Delta:/opt/dsf/plugins/FilamentLoadCell/dsf $ ls -ltotal 24-rwxrwxr-x 1 dsf dsf   36 Apr 25 18:47 foobar-rwxrwxr-x 1 dsf dsf 9247 Apr 25 17:07 weigh-rwxrwx--- 1 dsf dsf 7829 Apr 25 17:07 weigh_filament_endpoint.pyian@Delta:/opt/dsf/plugins/FilamentLoadCell/dsf $ ./foobar/usr/bin/python3: can't open file '/opt/dsf/plugins/FilamentLoadCell/dsf/./foobar': [Errno 13] Permission denied
same script, same ownership, same permissions. It does still work with 'python3 foobar', and if I run python interactively it can read and execute the file:

Code:

ian@Delta:~ $ python3Python 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] on linuxType "help", "copyright", "credits" or "license" for more information.>>> exec(open("/opt/dsf/plugins/FilamentLoadCell/dsf/./foobar").read())hello>>>
What causes this, and how do I fix it?

I've checked each directory down the path, and all have at least r-x for for all u g & o permissions.

Code:

ian@Delta:~ $ ls -al /opttotal 20drwxr-xr-x  5 root root 4096 Apr 25 18:36 .drwxr-xr-x 18 root root 4096 Apr 24 22:20 ..ian@Delta:~ $ ls -al /opt/dsftotal 48drwxr-xr-x 7 dsf  dsf   4096 Apr 19 20:54 .drwxr-xr-x 5 root root  4096 Apr 25 18:36 ..ian@Delta:~ $ ls -al /opt/dsf/plugins/total 32drwxr-xr-x 4 dsf dsf 4096 Apr 25 17:07 .drwxr-xr-x 7 dsf dsf 4096 Apr 19 20:54 ..ian@Delta:~ $ ls -al /opt/dsf/plugins/FilamentLoadCelltotal 16drwxrwxr-x 4 dsf dsf 4096 Apr 25 17:07 .drwxr-xr-x 4 dsf dsf 4096 Apr 25 17:07 ..ian@Delta:~ $ ls -al /opt/dsf/plugins/FilamentLoadCell/dsftotal 32drwxrwxr-x 2 dsf dsf 4096 Apr 25 18:38 .drwxrwxr-x 4 dsf dsf 4096 Apr 25 17:07 ..-rwxrwxr-x 1 dsf dsf   36 Apr 25 18:47 foobar-rwxrwxr-x 1 dsf dsf 9247 Apr 25 17:07 weigh-rwxrwx--- 1 dsf dsf 7829 Apr 25 17:07 weigh_filament_endpoint.py
The script is nothing special:

Code:

#!/usr/bin/python3print("hello")

Statistics: Posted by achrn — Thu Apr 25, 2024 6:13 pm



Viewing all articles
Browse latest Browse all 1225

Trending Articles