通过Python System/SubProcess CMD,在执行脚本中获取变量
我正在尝试在使用Python System()执行的Shell脚本中获得变量的值集。但是,我不知道如何执行OS.System()调用后如何获取该值。是否可以使用Python子过程命令获取它。
cmd = "script.sh --input1 "+ inputValue1 + " --input2 '"+ inputValue2 + "' --output-file " + pathToOutputFile
os.system(cmd)
执行执行某些函数时,执行过程中的脚本sh会设置一个本地变量。我想执行该变量的值post os.system()。是否将另一个参数传递给脚本并在system()完成时将其设置为脚本中的值并使用该值 - 是否可以使用python中的os.system()或subprocess()?
请帮助您使用可以在Python中获取可变值的任何代码段。
感谢您的指示。
I am trying to get a variable's value set inside shell script executed using python system(). HOwever I dont have idea how to fetch that value after os.system() call is executed. whether it can be fetched using the python subprocess command.
cmd = "script.sh --input1 "+ inputValue1 + " --input2 '"+ inputValue2 + "' --output-file " + pathToOutputFile
os.system(cmd)
The script.sh during execution sets one local variable when executing some function. I want to fetch that variable's value post os.system() is executed. Whether passing another argument to script and getting that value set inside script and use that value when system() is completed - is it possible using os.system() or subprocess() in python?
please help with any code snippet that can get the variable value in python.
thanks for your pointers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论