2

So I have a Bash script that does a bunch of things, one of them (actually the first one) is blink an LED on a RPi (via Python).

The problem is that when I run the Python script it blocks all other scripts and nothing else runs.

I think that by adding an & it runs in the background but that didn't make any difference when I tried it.

This is what I have:

#!/bin/bash
sudo python /scripts/blink.py blinkRed &
rm test.txt test.bkp
...

So basically everything stops after running the blink.py script.

Any ideas on how I could make it non-blocking, run it on another thread, on the background or something like that?

12
  • By the way, the Python script is an infinite loop while(1): ... Commented Apr 28, 2015 at 17:04
  • are you running the script as root? Commented Apr 28, 2015 at 17:08
  • can you please change the first line to #!/bin/bash -x to confirm that everything runs as expected (and post the output) Commented Apr 28, 2015 at 17:09
  • @ReutSharabani well kind of, it's being run by www-data actually, but it has root access Commented Apr 28, 2015 at 17:11
  • 1
    "So basically everything stops after running the blink.py script." and "By the way, the Python script is an infinite loop " So, strictly speaking, there is no "after running the script" as the script never terminates. Couldn't you be fooled by some kind or race condition-like -- the "rest" of the script being executed before the background Python process had even time to start ? In addition, how does behave sudo in that case regarding asking the password (maybe it isn't required given your configuration ?) Commented Apr 28, 2015 at 17:28

1 Answer 1

2

If you have all permissions needed, don't use sudo. It is probably waiting for a password to change permissions.

Give the user who runs the script all permissions needed and remove the sudo.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.