Closed G109B closed 3 years ago
Just close the connection. Your telnet connection goes to the procServ server, not to the program itself. If you disconnect, procServ will continue to run your program in the background, that's the whole point of procServ. Whenever you are back on your system, just telnet to the procServ port and you will be connected to your program again.
Thanks Ralph for your rapid reply. I haven't described my problem very well, so here is another attempt: The program running under procserv is part of a package which communicates with an APRS server, potentially for ever. The author runs it under procserv so that the program's input and output can be observed by connecting to a specific port, typically by telnet. I want to pipe this stream of text into a perl program, and this is successful in the foreground. eg: telnet localhost 1234 | myprog.pl (actually, but not necessarily, held in a script file). I have tried many ways of running this permanently (nohup, &, etc.) but they all quit immediately with the message "Connection closed by foreign host", which I am assuming is procserv objecting to stdin being closed. Am I correct, or am I missing something obvious ?
You probably should be using something other than telnet for that then, such as nc
(netcat), or bash does TCP socket redirection (so in bash you would run myprog.pl < /dev/tcp/localhost/1234
). Personally I would probably have the Perl script open its own TCP connection to the procServ port instead of reading stdin.
Understood. Have you tried using the logging port? That's the intended way to connect read-only to the program running under procServ.
You probably should be using something other than telnet for that then, such as
nc
(netcat), or bash does TCP socket redirection (so in bash you would runmyprog.pl < /dev/tcp/localhost/1234
). Personally I would probably have the Perl script open its own TCP connection to the procServ port instead of reading stdin.
/dev/tcp/localhost/port was a huge gap in my knowledge, and appears to solve the problem. Many thanks for that.
Understood. Have you tried using the logging port? That's the intended way to connect read-only to the program running under procServ.
Thanks again Ralph, I guess '-l newport' is an option I had missed, although it would involve some changes to scripts which come with the package.
Many thanks for your help Ralph and Andrew, I went with reading TCP direct from Perl (another gap in my knowledge) and it is working perfectly. Surprisingly easy to implement too.
procserv is running a program which requires no input. I can obtain its output stream using 'telnet localhost port' no problem. However 'telnet localhost port </dev/null' gets chucked off with "connection closed by foreign host". Is there an option to prevent this ? Why do I ask ? Because I want to leave it running after I log off, and all of the usual suspects hit this snag.