1
我正想通過Pexpect的文檔,它說你可以調用run()函數來執行命令並返回輸出一種新型的國際展覽局澄清Pexpect的模塊上
所以我做了以下,但它出錯了。我在這裏錯過了什麼嗎?
>>> pexpect.run('pwd')
'/home/vijay\r\n'
>>> pexpect.run('cd /home')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/pexpect.py", line 219, in run
child = spawn(command, maxread=2000, logfile=logfile, cwd=cwd, env=env)
File "/usr/lib/python2.7/dist-packages/pexpect.py", line 429, in __init__
self._spawn (command, args)
File "/usr/lib/python2.7/dist-packages/pexpect.py", line 516, in _spawn
raise ExceptionPexpect ('The command was not found or was not executable: %s.' % self.command)
pexpect.ExceptionPexpect: The command was not found or was not executable: cd.
>>>
我寫上,我下載一個Git倉庫的腳本,並希望進行CD(到庫),然後通過一些命令。所以我決定使用pexpect模塊,因爲它提供了交互式控制檯
讓我知道如果我在這裏丟失什麼?
感謝, -Vijay
cd不是linux中的命令,它是一個內置函數,它構成了你的shell。 – Blubber
謝謝..這有幫助! – user596922