获取 C 中 Shell 命令的结果

发布于 2024-08-13 09:19:37 字数 150 浏览 3 评论 0原文

我试图找到一个函数来调用系统命令(shell 命令)并在 C 程序中返回其结果。 我只找到了像 system 这样的函数,但这些函数不返回命令的结果。

我只知道 perl : my $results = ``my shell command` ;

谢谢!

I'm trying to find a function to call a system command (shell command) and get back its result in a C program.
I only found functions like system but these don't return the result of the command.

I just know it in perl : my $results = ``my shell command` ;

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

别把无礼当个性 2024-08-20 09:19:37

您至少在寻找 popen()在 POSIX(Linux 等)系统上。在 Windows 中,可能需要不同的解决方案。

You're looking for popen(), at least on POSIX (Linux etc) systems. In Windows, a different solution is likely needed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文