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

Execute a shell command and emit events triggered by stdOut #1208

Closed
hschneider opened this issue Feb 24, 2024 · 3 comments
Closed

Execute a shell command and emit events triggered by stdOut #1208

hschneider opened this issue Feb 24, 2024 · 3 comments

Comments

@hschneider
Copy link

hschneider commented Feb 24, 2024

Is your feature request related to a problem? Please describe.
When executing long-running shell commands, it is not possible to track progress. even if the command sends progress info via stdOut. We can display an infinite progress bar or another indicator to the user, but there is no real live-info.

Describe the solution you'd like

  • Each data sequence terminated with a linefeed, coming from stdOut is read into a buffer.
  • Next a JS event is triggered in the frontend, called e.g. progress.
  • This event receives the buffered, raw data as a string for further processing.
  • The buffer is cleared and the next line is read from stdOut.
  • Loop until command terminates.
  • When the command has been terminated an additional event called progress_end could be triggered.

Describe alternatives you've considered
No alternatives, as far as I can see ....

@hschneider hschneider changed the title Execute a shell command and emit events via stdOut Execute a shell command and emit events triggered by stdOut Feb 24, 2024
@JustPilz
Copy link

https://neutralino.js.org/docs/api/os/#osspawnprocesscommand-cwd

But curl push progress data in stdErr

@hschneider
Copy link
Author

Right, so the same for stdErr would be useful, maybe the events should be better named cmd_stdout and cmd_stderr triggered line by line and cmd_start and cmd_end triggered before start and after end of the external process.

@hschneider
Copy link
Author

Ooops - missed this one: os.spawnProcess(command, cwd)
@JustPilz Thanks for the hint.
Think we can close this :-)

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

No branches or pull requests

2 participants