我将netcat用于UNIX.
I'm using the netcat for unix.
当我运行 python script.py&logfile.txt ,它会被连续捕获.
when I run python script.py &> logfile.txt , it gets captured continuously.
要远程复制此文件,我在侦听器(客户端)上尝试了 nc -l -p 8011 ,在发送方(主机或服务器)上尝试了以下操作:
To replicate this remotely, I tried nc -l -p 8011 on the listener (client) and the following for the sender (host or server) :
但是似乎没有任何效果.请帮忙.
But nothing seems to work. Please help.
推荐答案这是您要的吗?
接收器:
nc -l 8011 >logfile.txt发件人:
python script.py 2>&1 | nc 127.0.0.1 8011确保首先运行接收器代码.
Make sure to run the receiver code first.
编辑:如果您不知道有很多不同版本的netcat ;它们都接受略有不同的参数(例如Debian上的 nc.traditional 希望 nc -l -p 1234 监听端口1234,而BSD nc (例如OS X)只希望 nc -l 1234 和 ncat 可能引发一个有趣的错误,除非您的主机没有使用 -4 标志'不支持IPv6)-请阅读手册页,以了解您真正想要的选项组合.
EDIT: In case you're not aware there's a lot of different versions of netcat; they all accept slightly different arguments (e.g. nc.traditional on Debian wants nc -l -p 1234 to listen on port 1234, whereas BSD nc (e.g. OS X) just wants nc -l 1234 and ncat may throw an interesting error unless you use the -4 flag if your host doesn't support IPv6) - read the man pages to find out what combination of options you actually want.
更多推荐
有没有一种方法可以将命令输出中的连续流发送到远程侦听器
发布评论