linux - 通过 execlp 执行带有特定输出的命令 ps

标签 linux shell

我只能显示 PPID、可执行文件名称和 CPU 使用率列。我必须通过 execlp 执行命令 ps,但我找不到它工作的正确语法。有什么建议吗?

我尝试了 execlp("ps","ps", "-o","ppid cmd cpu", (char *) NULL);

和类似的事情,但它仍然不起作用

最佳答案

你可以试试这个

execlp("ps","ps", "-o","ppid,cmd,cpu", (char *) NULL);

关于linux - 通过 execlp 执行带有特定输出的命令 ps,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22451692/

相关文章:

java - 用户密码校验

linux - MQ ksh shell 脚本 - 陷阱错误

linux - 如何编写文件创建脚本?

ios - XCode 8 卡在运行 4 个自定义 Shell 脚本中的第 2 个

bash - 消息 "syntax error near unexpected token ` ('"

c++ - VS 代码 "command": "make" differs from command line `make` in terminal window

c - 显示目录中的文件

php - 在控制台上执行php脚本

linux - 我想将 Bash 脚本的所有命令行参数存储到单个变量中

shell - 如何在makefile函数中传递逗号字符