我想创建一个bash(或者zsh,没关系。)服务器,它接受命令,运行它们并返回结果(return code, stdout, stderr)。我的目的是避免为我想在脚本中运行bash的每个命令启动一个新实例,因为我的点文件需要很长时间才能加载。本着以下精神的东西:bashPythonbash
bash = bash_instance() # pay the startup penalty ONCE
bash.run('echo hi') # Just run the command without the startup time
...
bash.run('curl ipinfo.io')
return_code, stdout, stderr = bash.run('cat file.txt')
一种Remote Method Call为壳。