I have an "alarm email" function inside a python module. I want to be able to call this function from a bash script. I know you can call a module using 'python ' in the script, but I'm not if you can or how you would call a specific function within the module.
We can make use of the bash script to run the Python script in macOS/Ubuntu. Both these operating systems support bash scripts. Let's see the steps to run Python scripts using a bash script. Open any text editor.
To invoke a bash function, simply use the function name. Commands between the curly braces are executed whenever the function is called in the shell script. The function definition must be placed before any calls to the function.
%%bash. Means, that the following code will be executed by bash. In bash $() means it will return with the result of the commands inside the parentheses, in this case the commands are: gcloud config list project --format "value(core.project)" Google cloud has its own command set to control your projects.
python -c'import themodule; themodule.thefunction("boo!")'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With