【发布时间】:2020-01-10 08:27:03
【问题描述】:
无论如何要把脚本集成到操作系统中?
例如,我有一个名为 getInfo 的文件
getInfo 是这个文件:
KEY=$(grep -i -e "^$1:" username.sql |sed 's/.*://')
grep -e "^$KEY" info.txt | cut -d ':' -f 2
细节并不重要,但基本上它只是获取一些用户名的信息。 bash 中的示例
$ ./getInfo username1
Hello
在python中会是
import os
os.system('./getInfo username1')
我会在 bash 上运行这个 python 文件
$ python this.py
'KEY' is not recognized as an internal or external command, operable program or batch file.
有没有办法在 python 中完成这个?
【问题讨论】:
-
getInfo 有合适的 shebang 行来用 bash 运行它吗?
标签: python bash python-2.7