curl-抑制c -popen(...)语句中的stdout标头显示
在Linux C程序中,我打电话
FILE *fd = popen("curl ipecho.net/plain", "r");
fgets(buffer, BUFFER_CONTENTS_MAX, fd);
pclose(fd);
给将计算机的IP地址存储到缓冲区中,然后仅返回IP地址(加上我剥离的其他一些东西)。它可以正常工作,但是在通话过程中,尽管“/plain”开关,但在通话过程中会回荡到标头。如何抑制Stdout输出?不需要的输出看起来像:
%收到%XFERD平均速度时间时间的百分比百分比 当前的 Dload上传总左速度100 11 100 11 0 0 86 0 - : - : - - : - : - - - - : - : - 85
In a Linux C program, I call
FILE *fd = popen("curl ipecho.net/plain", "r");
fgets(buffer, BUFFER_CONTENTS_MAX, fd);
pclose(fd);
to store my machine's IP address into a buffer, and it returns just the IP address (plus some other stuff which I strip off). It works fine, but during the call, CURL echoes a header to stdout despite the "/plain" switch. How can I suppress the stdout output? The unwanted output winds up looking like:
% Total % Received % Xferd Average Speed Time Time Time
Current
Dload Upload Total Spent Left Speed 100 11 100 11 0 0 86 0 --:--:-- --:--:--
--:--:-- 85
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论