1

I want to run two Python Scripts at the same time. I found that using Bash you can do that. So i wrote the next code

#! /usr/bin/env bash import camera_centroid import testsss python camera_centroid.py & python testsss.py &

When i run it i get a SyntaxError: invalid syntax Why?

2 Answers 2

1

Looks like you have mixed between python and bash, you don't need the import in the bash script.

#!/usr/bin/env bash
python camera_centroid.py &
python testsss.py &
wait # wait for jobs to be done

make sure you adding execute permissions to the scripts

chmod +x testsss.py camera_centroid.py

and finally run the script ./your_file.sh

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

Comments

1

When you write:

import foo

in a shell script, you are not importing the python module, instead, you are calling the $(which import) command/alias/function.

For example, if you have ImageMgick installed, very likely, you are making screenshot for window(s).

If you want to import python module, those import foo should be in your python files.

1 Comment

Conversely, you need to provide a specific path to camera_centroid.py and testsss.py as the arguments to the python command; bash has no way of locating them implicitly.

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.