Page 1 of 1

about automatically run python code

Posted: Fri Sep 08, 2023 3:44 am
by Cuijwyn
I have a python code that can run SBC4 with SSH, but I upload to SBC with SBC4 web, and make it run automatically, but it does not work, and give the errors:
/usr/userapps/python/removeOldMiniseed.py: 7: /usr/userapps/python/removeOldMiniseed.py:
Created on Thu Jul 6 22:13:14 2023

@author: cuijw
: not found
/usr/userapps/python/removeOldMiniseed.py: 9: /usr/userapps/python/removeOldMiniseed.py: import: not found
/usr/userapps/python/removeOldMiniseed.py: 10: /usr/userapps/python/removeOldMiniseed.py: import: not found
from: can't read /var/mail/threading
/usr/userapps/python/removeOldMiniseed.py: 13: /usr/userapps/python/removeOldMiniseed.py: Syntax error: "(" unexpected

I add #!/usr/userapps/python/ in the code head , then I get error: /etc/webif/init.d/S20python: 41: /etc/webif/init.d/S20python: /usr/userapps/python/removeOldMiniseed.py: Permission denied

How should I do?

Re: about automatically run python code

Posted: Fri Sep 08, 2023 12:51 pm
by Patrick
Hi,

You need to add to the start of your .py file:

#!/usr/bin/env python3

-Patrick