Keep telnet connection open in background and send output to file
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
Some background: Working with ash shell (busybox) on an embedded device. From a script, I need to keep a local telnet connection open in the background to monitor the output of a service running locally on the device so I can perform actions based on that output. I do not have expect, script, nc available. To clarify, this service is playing an internet radio stream. It will output the current song information in a telnet session when the track changes, and that is what I need to capture specifically.
How can I keep a persistant telnet session open in the background and using custom file descriptors or named pipes read and/or write to the session? My understanding of the syntax for redirects is lacking at best.
EDIT:
I believe I'm on the right track. Again I'm still unclear about custom FD's and named pipes. Truth be told I'm not sure if I need to open FD 6 for reading AND writing. If anyone wants to clarify this syntax for me or suggest a more efficient or reliable method please do.
mkfifo "INPUTPIPE"
exec 6<> "INPUTPIPE"
telnet "HOST" "PORT" <&6 >> "OUTPUTFILE" &
EDIT AGAIN:
The above has been working well for my needs. Telnet remains persistent in the background, and scripts can now parse the lines output from the telnet session by reading "OUTFILE". I'm hesitant to answer however as I would still like someone with more experience to either demonstrate a "more correct" syntax and/or explain this better than I can.
scripting busybox telnet fifo ash
add a comment |Â
up vote
0
down vote
favorite
Some background: Working with ash shell (busybox) on an embedded device. From a script, I need to keep a local telnet connection open in the background to monitor the output of a service running locally on the device so I can perform actions based on that output. I do not have expect, script, nc available. To clarify, this service is playing an internet radio stream. It will output the current song information in a telnet session when the track changes, and that is what I need to capture specifically.
How can I keep a persistant telnet session open in the background and using custom file descriptors or named pipes read and/or write to the session? My understanding of the syntax for redirects is lacking at best.
EDIT:
I believe I'm on the right track. Again I'm still unclear about custom FD's and named pipes. Truth be told I'm not sure if I need to open FD 6 for reading AND writing. If anyone wants to clarify this syntax for me or suggest a more efficient or reliable method please do.
mkfifo "INPUTPIPE"
exec 6<> "INPUTPIPE"
telnet "HOST" "PORT" <&6 >> "OUTPUTFILE" &
EDIT AGAIN:
The above has been working well for my needs. Telnet remains persistent in the background, and scripts can now parse the lines output from the telnet session by reading "OUTFILE". I'm hesitant to answer however as I would still like someone with more experience to either demonstrate a "more correct" syntax and/or explain this better than I can.
scripting busybox telnet fifo ash
2
If you don't havenetcat
(nc
) orsocat
you're going to be fighting a losing battle.
â roaima
Sep 25 '17 at 22:14
What specifically makes nc better than telnet for this scenario just out of curiosity?
â sunshine
Sep 25 '17 at 22:46
Look at DJB's ucspi-tcp and related utilities (such as daemontools). Take your time to understand how things are supposed to work together.
â Satà  Katsura
Sep 26 '17 at 7:42
I believe me asking here is an attempt at understanding <3
â sunshine
Feb 19 at 8:54
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Some background: Working with ash shell (busybox) on an embedded device. From a script, I need to keep a local telnet connection open in the background to monitor the output of a service running locally on the device so I can perform actions based on that output. I do not have expect, script, nc available. To clarify, this service is playing an internet radio stream. It will output the current song information in a telnet session when the track changes, and that is what I need to capture specifically.
How can I keep a persistant telnet session open in the background and using custom file descriptors or named pipes read and/or write to the session? My understanding of the syntax for redirects is lacking at best.
EDIT:
I believe I'm on the right track. Again I'm still unclear about custom FD's and named pipes. Truth be told I'm not sure if I need to open FD 6 for reading AND writing. If anyone wants to clarify this syntax for me or suggest a more efficient or reliable method please do.
mkfifo "INPUTPIPE"
exec 6<> "INPUTPIPE"
telnet "HOST" "PORT" <&6 >> "OUTPUTFILE" &
EDIT AGAIN:
The above has been working well for my needs. Telnet remains persistent in the background, and scripts can now parse the lines output from the telnet session by reading "OUTFILE". I'm hesitant to answer however as I would still like someone with more experience to either demonstrate a "more correct" syntax and/or explain this better than I can.
scripting busybox telnet fifo ash
Some background: Working with ash shell (busybox) on an embedded device. From a script, I need to keep a local telnet connection open in the background to monitor the output of a service running locally on the device so I can perform actions based on that output. I do not have expect, script, nc available. To clarify, this service is playing an internet radio stream. It will output the current song information in a telnet session when the track changes, and that is what I need to capture specifically.
How can I keep a persistant telnet session open in the background and using custom file descriptors or named pipes read and/or write to the session? My understanding of the syntax for redirects is lacking at best.
EDIT:
I believe I'm on the right track. Again I'm still unclear about custom FD's and named pipes. Truth be told I'm not sure if I need to open FD 6 for reading AND writing. If anyone wants to clarify this syntax for me or suggest a more efficient or reliable method please do.
mkfifo "INPUTPIPE"
exec 6<> "INPUTPIPE"
telnet "HOST" "PORT" <&6 >> "OUTPUTFILE" &
EDIT AGAIN:
The above has been working well for my needs. Telnet remains persistent in the background, and scripts can now parse the lines output from the telnet session by reading "OUTFILE". I'm hesitant to answer however as I would still like someone with more experience to either demonstrate a "more correct" syntax and/or explain this better than I can.
scripting busybox telnet fifo ash
scripting busybox telnet fifo ash
edited Sep 26 '17 at 18:08
asked Sep 25 '17 at 22:00
sunshine
64
64
2
If you don't havenetcat
(nc
) orsocat
you're going to be fighting a losing battle.
â roaima
Sep 25 '17 at 22:14
What specifically makes nc better than telnet for this scenario just out of curiosity?
â sunshine
Sep 25 '17 at 22:46
Look at DJB's ucspi-tcp and related utilities (such as daemontools). Take your time to understand how things are supposed to work together.
â Satà  Katsura
Sep 26 '17 at 7:42
I believe me asking here is an attempt at understanding <3
â sunshine
Feb 19 at 8:54
add a comment |Â
2
If you don't havenetcat
(nc
) orsocat
you're going to be fighting a losing battle.
â roaima
Sep 25 '17 at 22:14
What specifically makes nc better than telnet for this scenario just out of curiosity?
â sunshine
Sep 25 '17 at 22:46
Look at DJB's ucspi-tcp and related utilities (such as daemontools). Take your time to understand how things are supposed to work together.
â Satà  Katsura
Sep 26 '17 at 7:42
I believe me asking here is an attempt at understanding <3
â sunshine
Feb 19 at 8:54
2
2
If you don't have
netcat
(nc
) or socat
you're going to be fighting a losing battle.â roaima
Sep 25 '17 at 22:14
If you don't have
netcat
(nc
) or socat
you're going to be fighting a losing battle.â roaima
Sep 25 '17 at 22:14
What specifically makes nc better than telnet for this scenario just out of curiosity?
â sunshine
Sep 25 '17 at 22:46
What specifically makes nc better than telnet for this scenario just out of curiosity?
â sunshine
Sep 25 '17 at 22:46
Look at DJB's ucspi-tcp and related utilities (such as daemontools). Take your time to understand how things are supposed to work together.
â Satà  Katsura
Sep 26 '17 at 7:42
Look at DJB's ucspi-tcp and related utilities (such as daemontools). Take your time to understand how things are supposed to work together.
â Satà  Katsura
Sep 26 '17 at 7:42
I believe me asking here is an attempt at understanding <3
â sunshine
Feb 19 at 8:54
I believe me asking here is an attempt at understanding <3
â sunshine
Feb 19 at 8:54
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f394419%2fkeep-telnet-connection-open-in-background-and-send-output-to-file%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
2
If you don't have
netcat
(nc
) orsocat
you're going to be fighting a losing battle.â roaima
Sep 25 '17 at 22:14
What specifically makes nc better than telnet for this scenario just out of curiosity?
â sunshine
Sep 25 '17 at 22:46
Look at DJB's ucspi-tcp and related utilities (such as daemontools). Take your time to understand how things are supposed to work together.
â Satà  Katsura
Sep 26 '17 at 7:42
I believe me asking here is an attempt at understanding <3
â sunshine
Feb 19 at 8:54