Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read until blank line #22

Open
heyitsols opened this issue Jul 30, 2021 · 1 comment
Open

Read until blank line #22

heyitsols opened this issue Jul 30, 2021 · 1 comment

Comments

@heyitsols
Copy link

heyitsols commented Jul 30, 2021

Hello,

I am using your library as part of connecting to systems to run a command, read the output, and then run another command. The system in question doesn't have a character as its prompt (e.g. no $ or >) and as such, I can't figure out what I should be passing to the ReadUntil() function. I was using a carriage return string "\r" but this isn't always effective as the output can be multiple lines.

Have you accounted for this use case?

Many thanks

EDIT: Perhaps there is some way to define a regex pattern that is matched?

@ziutek
Copy link
Owner

ziutek commented Aug 2, 2021

Your problem is parsing unformatted text without clear delimiters.

This package provides only very cheap and therefore very primitive parsing functions. You can do anything you want wrapping plain Read or ReadByte methods and analyze the input text yourself.

If there is no way to detect the message boundaries from its content you can use timeouts by setting SetReadDeadline on underlying net.Conn or using another goroutine to reading from the connection and sending on a channel (use select with time.After to implement a timeout on the channel).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants