我使用popen
來執行type -t type
,這給我一個錯誤信息-t
找不到。當我在shell中執行type -t type
時,這給我內置。爲什麼這不適用於popen
?在linux中使用type -t命令c。?
0
A
回答
0
POSIX指定與popen
一起使用的外殼是/bin/sh
。您的交互式shell可能是bash
。 type
命令的行爲與sh
和bash
不同。 sh
不支持-t
。
您的系統可能有/bin/sh
符號鏈接到/bin/dash
,但這只是一個實現細節。
如果需要bash
行爲,運行bash
明確:
popen("/bin/bash -c 'type -t type'", "r")
相關問題
- 1. 如何在C++中使用linux命令?
- 2. 使用execv在linux中使用'./'命令
- 3. 在plsql中的TYPE命令
- 4. 使用Linux命令
- 5. 使用Linux命令
- 6. 如何在linux中使用exec命令使用wget命令?
- 7. Linux AT&T的命令行參數
- 8. 在crontab中使用linux命令輸出
- 9. 在Linux中使用sar命令
- 10. 在php中使用Linux awk命令
- 11. 在Linux中使用Mac OS命令'codesign'
- 12. 在Linux中使用Grep命令
- 13. 在Linux命令行中使用分號
- 14. 如何在JavaScript中使用linux命令?
- 15. 在bashrc中使用linux「tee」命令
- 16. 在linux中使用睡眠命令
- 17. 在C++中使用linux命令行的分段錯誤
- 18. 如何使用gcc彙編命令(.type)?
- 19. 使用desc命令時縮短'type'列
- 20. 排序使用Linux命令
- 21. 要使用Linux命令
- 22. 如何使用Linux命令
- 23. 使用linux腳本命令
- 24. 使用Linux命令外殼
- 25. 使用sed linux命令
- 26. Windows CMD TYPE命令
- 27. C++ linux系統命令
- 28. 用C程序調用linux命令cmp
- 29. 使用xargs多次在一個命令在linux命令行
- 30. 在c中使用cd命令c
也許顯示你寫的代碼?這是編譯器錯誤消息還是運行時錯誤? – UnholySheep
FILE * file = popen(「type -t type」,「w」);此錯誤在運行時出現在標準輸出中。當我直接在shell中使用type -t類型時,我得到了內建的。 (沒有錯誤) – Ellebasi