0

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
  • 26,737
  • 24
  • 105
  • 146
Sorry
  • 41
  • 1
  • 2
  • 8
  • 2
    Possible duplicate of [Calling a Python function from a shell script](http://stackoverflow.com/questions/8567526/calling-a-python-function-from-a-shell-script) – mishik Mar 06 '16 at 19:18

1 Answers1

1
python -c 'import test; print test.foo(param)'
Henin RK
  • 298
  • 1
  • 2
  • 14
  • If you are satisfied with the answer can you mark it as answered – Henin RK Mar 06 '16 at 19:43
  • 5
    Please start writing halfway-decent answers with explanations, not just code dumps, and stop hassling OPs to accept. – jonrsharpe Mar 06 '16 at 19:50
  • 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"? – Sorry Mar 06 '16 at 21:10