Score:0

Forward terminal output to localhost port

cn flag

I am new to tcp. Suppose I have a command to run on terminal that prints output line by line. How do I forward that output to a localhost port so that I can read it with other apps written in Python. From this thread, I set up a listening terminal with:

nc -l 2003

using port 2003. Then I run my command like this :

mycommand | netcat localhost 2003

But nothing goes through.

If I test with

echo hello_world | netcat localhost 2003

I can receive the hello_world though. How do I create this transfer?

The command is a kafka-console-consumer.sh like this:

bin/kafka-console-consumer --topic <topic_name> --from-beginning --bootstrap-server <dns:port> | netcat localhost 2003
hr flag
Perhaps `your_command` output is being buffered? See for example [Make netcat a “stream”](https://unix.stackexchange.com/questions/302366/make-netcat-a-stream)
Tristan Tran avatar
cn flag
Thanks. You were right.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.