2

我有一个 python GUI,我想运行一个 shell 命令,你不能使用 windows cmd 执行我已经安装了 cygwin,我想知道如何运行 cygwin 而不是 windows cmd。我想使用 subprocess 并获取 .sh 文件的结果,但我的代码

subprocess.check_output("./listChains.sh < 2p31protein.pdb")

这将在 cmd 中运行它,因为 windows 无法识别它,它不会工作,所以我怎样才能让它在 cygwin 而不是 cmd 中运行

4

2 回答 2

2

执行一个 cygwin shell(例如bash)并让它运行你的脚本,而不是直接运行你的脚本:

subprocess.check_output("C:/cygwin/bin/bash.exe ./listChains.sh < 2p31protein.pdb")

或者,将.sh要打开的文件类型扩展名与bash.exe.

于 2012-12-27T14:01:44.870 回答
1

使用 python 子进程运行 cygwin 可执行文件要求 ./bin 目录cygwin1.dll位于 Windows 路径上。cygwin1.dll向 Windows 公开 cygwin 可执行文件,允许它们在 Windows 命令行中运行并被 Python 子进程调用。

于 2015-12-28T14:54:00.287 回答