Is there any way to call a shell script and use the functions/variable defined in the script from python?
The script is unix_shell.sh
#!/bin/bash fun
With the help of above answer and this answer, I come up with this:
import subprocess command = 'bash -c "source ~/.fileContainingTheFunction && theFunction"' stdout = subprocess.getoutput(command) print(stdout)
I'm using Python 3.6.5 in Ubuntu 18.04 LTS.