linux – Netcat命令行问题

linux – Netcat命令行问题,第1张

概述我试图使用netcat从memcached服务器收集统计信息. ~ $nc 10.251.170.80 11211statsSTAT pid 27508STAT uptime 7940345STAT time 1262949310STAT version 1.2.4STAT pointer_size 64STAT rusage_user 1389.962693STAT rusage 我试图使用netcat从memcached服务器收集统计信息.
~ $nc 10.251.170.80 11211statsSTAT pID 27508STAT uptime 7940345STAT time 1262949310STAT version 1.2.4STAT pointer_size 64STAT rusage_user 1389.962693STAT rusage_system 4857.247586STAT curr_items 9154565STAT total_items 615722800STAT bytes 1994844049STAT curr_connections 62STAT total_connections 6263004STAT connection_structures 148STAT cmd_get 1925983531STAT cmd_set 615722800STAT get_hits 1334407705STAT get_misses 591575826STAT evictions 7125864STAT bytes_read 454794886199STAT bytes_written 176758890326STAT limit_maxbytes 2147483648STAT threads 4END

我无法理解为什么

~ $echo stats | nc -vv 10.251.170.80 11211Connection to 10.251.170.80 11211 port [tcp/*] succeeded!~ $

只是失败了.

有没有一个技巧nc没有正确读取标准输入?

CR / LF出了什么问题?

我一直在尝试与输入(-C)相关的每个nc命令行选项

~ $echo $SHELL/bin/bash~ $bash --versionGNU bash,version 3.2.33(1)-release (i386-redhat-linux-gnu)copyright (C) 2007 Free Software Foundation,Inc.

该系统是fedora 9.

解决方法 这对我使用nc.openbsd和nc.Traditional都适用于debian:
echo -e "stats\nquit" | nc 10.251.170.80  11211

您的netcat似乎正在关闭stdin上的EOF连接而不是等待输出..
你可以尝试-q 1左右..

-q seconds after EOF on stdin,wait the specifIEd number of seconds and then quit. If seconds is negative,wait forever.

总结

以上是内存溢出为你收集整理的linux – Netcat命令行问题全部内容,希望文章能够帮你解决linux – Netcat命令行问题所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/1041377.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-24
下一篇 2022-05-24

发表评论

登录后才能评论

评论列表(0条)

保存