我使用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. 在plsql中的TYPE命令
- 3. 使用Linux命令
- 4. 使用c执行linux命令
- 5. 在php中使用Linux awk命令
- 6. 如何在JavaScript中使用linux命令?
- 7. 在linux中使用睡眠命令
- 8. 在Linux中使用Grep命令
- 9. 如何使用gcc汇编命令(.type)?
- 10. 使用desc命令时缩短'type'列
- 11. 排序使用Linux命令
- 12. Windows CMD TYPE命令
- 13. 使用xargs多次在一个命令在linux命令行
- 14. 用C程序调用linux命令cmp
- 15. 在c中使用cd命令c
- 16. 命令最后在Linux中
- 17. 在Linux中执行命令
- 18. 如何从使用命令行,在linux
- 19. Linux命令用法
- 20. 在Linux下的c execl命令ubuntu
- 21. 运行在C Linux命令++程序
- 22. c文件中的linux命令行
- 23. 用户输入到C命令的linux命令
- 24. 用Linux制作命令行命令
- 25. 在MATLAB中调用Linux命令行
- 26. 在c#中使用DbCommand执行命令#
- 27. 在Jenkins中使用linux命令在windows shell中
- 28. Linux xargs命令
- 29. linux命令setsid
- 30. linux tail命令
也许显示你写的代码?这是编译器错误消息还是运行时错误? – UnholySheep
FILE * file = popen(“type -t type”,“w”);此错误在运行时出现在标准输出中。当我直接在shell中使用type -t类型时,我得到了内建的。 (没有错误) – Ellebasi