2012-03-31 32 views
1

我遇到了bpython並試圖在cygwin的幫助下將其安裝在我的Windows系統上。現在,無論何時我必須訪問bpython程序,我必須打開cygwin並在cygwin shell內寫入bpython。通過Python程序將參數傳遞給Cygwin

現在我想自動使用蟒蛇script.So上述過程中,只要我在窗戶command prompt它應該直接開bpython shell我寫bpython.py

我的代碼:

import subprocess 
subprocess.call('F:\cygwin\Cygwin.bat') 

使用上面的代碼中,我能夠創造cygwin的過程,但不是一次我在Cygwin的終端寫bpython得到它的工作。

enter image description here

所以,我想知道我可以直接通過bpythonargumentF:\cygwin\Cygwin.bat

F:\cygwin\Cygwin.bat bpython 

可以直接打開bpython外殼。

或者是有可能的是

1)首先,我創建cygwin過程與subprocess模塊的幫助。

2)比我通過bpython作爲參數。

上述任務都由python程序完成,以便最終結果是bpython shell。

輸出的

which bpython

enter image description here

+0

是什麼'這bpython'返回內部Cygwin外殼? – 2012-03-31 05:15:06

+0

@ IgnacioVazquez-Abrams:它返回'/ usr/bin/bpython'。請參閱編輯。 – RanRag 2012-03-31 05:24:11

回答

3

創建(以下內容)bpython.bat命名的文件,並把它放在一個目錄在Windows PATH

@C:\cygwin\bin\bash.exe --login -c /usr/bin/bpython 
+0

我在上面提到的代碼中添加了'bpython.bat'到windows'path',但是如果我在''命令提示符下'寫'bpython',它不起作用,但是如果我寫'C:\ cygwin \ bin \ bash。 exe --login -c bpython'在我的命令提示符下工作得很完美。 – RanRag 2012-03-31 05:39:43

+0

@Noob:我的意思是用我的答案中的代碼創建一個名爲'bpython.bat'的文件,並將它放在Windows'PATH'中的一個目錄中;不要直接將該代碼添加到'PATH'。 – icktoofay 2012-03-31 05:41:21

+0

我也這樣做了,但結果相同。 – RanRag 2012-03-31 05:43:21

相關問題