Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux BASH-当需要时,如何使日志文件可通过TCP端口访问?_Linux_Bash_Tcp - Fatal编程技术网

Linux BASH-当需要时,如何使日志文件可通过TCP端口访问?

Linux BASH-当需要时,如何使日志文件可通过TCP端口访问?,linux,bash,tcp,Linux,Bash,Tcp,如何使TCP端口上的日志可用,以便其他人可以对其进行远程测试?例如: MAINSERVER> tail -f /etc/httpd/logs/access_log | grep -e fruit_Python -e fruit_BASH -e fruit_C | .... TCP 9999 ... make this available ....?? 现在,我想从我的笔记本电脑远程执行以下临时操作: MYLAPTOP> tail -f http://MAINSERVER:9999

如何使TCP端口上的日志可用,以便其他人可以对其进行远程测试?例如:

MAINSERVER> tail -f /etc/httpd/logs/access_log | grep -e fruit_Python -e fruit_BASH -e fruit_C | .... TCP 9999 ... make this available ....??
现在,我想从我的笔记本电脑远程执行以下临时操作:

MYLAPTOP> tail -f http://MAINSERVER:9999 | grep -e grab_BASH
有什么想法吗?

您可以使用netcat(nc)来执行此操作:

服务器端(侦听连接):

-我听着

-k在当前连接完成后侦听另一个连接

客户端(连接):

您也可以使用bash连接到/dev/tcp/host/port,但出于安全原因,有时不支持它(在bash中编译)

客户:

grep whatever_you_like < /dev/tcp/MAINSERVER/9999
grep任何您喜欢的内容
nc MAINSERVER 9999 | grep whatever_you_like
grep whatever_you_like < /dev/tcp/MAINSERVER/9999