Apr-19-2019, 12:34 PM
(This post was last modified: Apr-19-2019, 12:34 PM by Gribouillis.)
Here is how to store python code in a bash variable, run the python code from bash and store the output of the python code in another bash variable. THIS IS BASH CODE containing an inline block of python
#!/bin/bash read -r -d '' variable <<EOF import sys def hi(): print("hello world") hi() EOF result=`python3 -c "${variable}"` echo $result $result $resultMy output
Output:hello world hello world hello world