How to call a shell script function/variable from python?

前端 未结 6 1250
庸人自扰
庸人自扰 2021-01-19 01:56

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         


        
6条回答
  •  一整个雨季
    2021-01-19 02:22

    I do not know to much about python, but if You use export -f foo after the shell script function definition, then if You start a sub bash, the function could be called. Without export, You need to run the shell script as . script.sh inside the sub bash started in python, but it will run everything in it and will define all the functions and all variables.

提交回复
热议问题