Reticulum icon indicating copy to clipboard operation
Reticulum copied to clipboard

rncp does not output if piped

Open kujeger opened this issue 2 months ago • 5 comments

Running e.g. rncp -p | cat outputs nothing, while e.g. rnx -p | cat outputs identity information.

This makes e.g. parsing rncp -p to get the listening identity in scripts a bit tricky.

It seems rncp refuses to print anything when not run in an interactive tty?

kujeger avatar Oct 29 '25 11:10 kujeger

Can you provide the complete commands you are using to reproduce this? Of course, just strip any destination hashes / filenames.

markqvist avatar Oct 29 '25 11:10 markqvist

running rncp -p | cat in a terminal is the minimal example that outputs nothing. The full use in my script is

rncp -p | grep Listen 
rnx -p | grep Listen
rnsh -p | grep Listen

In order to quickly grab the listening identity for all these tools; both rnx and rnsh work here.

edit: to clarify, this is all in a plain old linux terminal, or in a bash/sh script

kujeger avatar Oct 29 '25 11:10 kujeger

Full example with outputs from my terminal (I realize rnsh is not a part of reticulum proper, just using it as an illustration):

$ rncp -p | cat
{nothing}

$ rnx -p | cat
Identity     : <0d[..]>
Listening on : <8d[..]>

$ rnsh -p | cat
Identity     : <32[..]>
$ rncp -p
Identity     : <07[..]>
Listening on : <dd[..]>

$ rnx -p
Identity     : <0d[..]>
Listening on : <8d[..]>

$ rnsh -p
Identity     : <32[..]>

kujeger avatar Oct 29 '25 11:10 kujeger

Can confirm. That is weird. This is gonna be an interesting one to fix...

markqvist avatar Oct 29 '25 11:10 markqvist

Straight after printing the "Listening on" line, RNS is exiting with os._exit(), so the output is not flushed to the pipe. Adding sys.stdout.flush() before the exit() should fix it, or terminating more gracefully via sys.exit().

skyguy avatar Oct 29 '25 13:10 skyguy