私はtftp
をpythonスクリプトから実行しようとしています。私はWindows 10の機能(http://www.trishtech.com/2014/10/enable-tftp-telnet-in-windows-10/)として有効にしたので、コマンドラインで実行することができます。しかし、私はPythonを介してそれを実行しようとすると、私はエラーが発生します。 os.system、subprocess.call、subprocess.Popen、および 'control'という3つのメソッドを呼び出して、これらのサブプロセスを使用して 'dir'を正常に呼び出しました。私は完全なパスからtftpを呼び出すことも試みました。下に貼り付けられたコードと出力。私は、解析を助けるために遅延といくつかの印刷を追加しました。Pythonで "windows features"を実行するにはどうすればいいですか?
これらのメソッドを使用すると、私が有効にした追加の「ウィンドウの機能」は、Pythonが見る環境の一部ではないと思います。しかし、私はどのように機能を含む環境を指定するか分からない!
call("dir", shell = True)
print "*******************************************"
time.sleep(1)
call("tftp", shell = True)
print "*******************************************"
time.sleep(1)
call("C:\Windows\System32\\tftp.exe", shell = True)
print "*******************************************"
time.sleep(1)
Popen("dir", shell = True)
print "*******************************************"
time.sleep(1)
Popen("tftp", shell = True)
print "*******************************************"
time.sleep(1)
Popen("C:\Windows\System32\\tftp.exe", shell = True)
print "*******************************************"
time.sleep(1)
os.system("dir")
print "*******************************************"
time.sleep(1)
os.system("tftp")
print "*******************************************"
time.sleep(1)
os.system("C:\Windows\System32\\tftp.exe")
print "*******************************************"
time.sleep(1)
そして私が手出力は次のようになります。正しい答えのための@eryksun:
Directory of C:\[REDACTED]
07/26/2016 11:05 AM <DIR> .
07/26/2016 11:05 AM <DIR> ..
07/26/2016 11:05 AM 1,724 [REDACTED].py
07/26/2016 11:05 AM 1,828 [REDACTED].pyc
07/23/2016 05:36 PM 1,933 prep_for_bootload.py
07/26/2016 07:52 AM 13 s.bat
07/26/2016 11:19 AM 1,449 scrap.py
07/26/2016 10:38 AM 672 test_script.py
07/26/2016 10:39 AM 90 upload_script.bat
7 File(s) 7,709 bytes
2 Dir(s) 222,286,884,864 bytes free
*******************************************
'tftp' is not recognized as an internal or external command,
operable program or batch file.
*******************************************
'C:\Windows\System32\tftp.exe' is not recognized as an internal or external command,
operable program or batch file.
*******************************************
*******************************************
Volume in drive C has no label.
Volume Serial Number is 2AC7-8D0E
Directory of C:\Users\[REDACTED]
07/26/2016 11:05 AM <DIR> .
07/26/2016 11:05 AM <DIR> ..
07/26/2016 11:05 AM 1,724 [REDACTED]
07/26/2016 11:05 AM 1,828 [REDACTED]
07/23/2016 05:36 PM 1,933 prep_for_bootload.py
07/26/2016 07:52 AM 13 s.bat
07/26/2016 11:19 AM 1,449 scrap.py
07/26/2016 10:38 AM 672 test_script.py
07/26/2016 10:39 AM 90 upload_script.bat
7 File(s) 7,709 bytes
2 Dir(s) 222,286,884,864 bytes free
*******************************************
'tftp' is not recognized as an internal or external command,
operable program or batch file.
*******************************************
'C:\Windows\System32\tftp.exe' is not recognized as an internal or external command,
operable program or batch file.
Volume in drive C has no label.
Volume Serial Number is 2AC7-8D0E
Directory of C:\Users\[REDACTED]
07/26/2016 11:05 AM <DIR> .
07/26/2016 11:05 AM <DIR> ..
07/26/2016 11:05 AM 1,724 [REDACTED]
07/26/2016 11:05 AM 1,828 [REDACTED]
07/23/2016 05:36 PM 1,933 prep_for_bootload.py
07/26/2016 07:52 AM 13 s.bat
07/26/2016 11:19 AM 1,449 scrap.py
07/26/2016 10:38 AM 672 test_script.py
07/26/2016 10:39 AM 90 upload_script.bat
7 File(s) 7,709 bytes
2 Dir(s) 222,286,884,864 bytes free
*******************************************
'tftp' is not recognized as an internal or external command,
operable program or batch file.
*******************************************
'C:\Windows\System32\tftp.exe' is not recognized as an internal or external command,
operable program or batch file.
*******************************************
あなたは 'tftp'コマンドがどこにあるのか探し出しましたが、手動で完全な場所から呼び出すだけでしたか?つまり、 'c:\ windows \ tftp.exe'にインストールされている場合は、pythonからフルパスで呼び出します。 – FrankerZ
はい、私も同様にこれを私のOPに追加しようとしました – MCM
'' \ t "'はタブ文字で、バックスラッシュとそれに続く "t"はありません。 –