This is my shell script, and I want to run the method foo(param):
#!/bin/sh
python /Users/username/Desktop/forTrump/test.py
How would I run a function inside test.py using the shell script above?
Martin Tournoij
28k24 gold badges110 silver badges158 bronze badges
-
2Possible duplicate of Calling a Python function from a shell scriptmishik– mishik2016年03月06日 19:18:57 +00:00Commented Mar 6, 2016 at 19:18
1 Answer 1
python -c 'import test; print test.foo(param)'
answered Mar 6, 2016 at 19:27
Henin RK
3081 gold badge2 silver badges14 bronze badges
Sign up to request clarification or add additional context in comments.
3 Comments
Henin RK
If you are satisfied with the answer can you mark it as answered
jonrsharpe
Please start writing halfway-decent answers with explanations, not just code dumps, and stop hassling OPs to accept.
Sorry
I would like to run this in a shell script with absolute path "/Users/username/Desktop/forTrump/test.py" I am not printing anything just running the method, which will run to a file, should I still include "print"?
default