On 06.08.19 13:29, Ido Rosenzwig wrote: > Hello cockpit-devel, > > I have a project, a cockpit plugin - cockpit-ovirt written in ReactJS. > In the project, I need to run a script that will run for a long time > (~20-30 minutes) that will be executed after an event has occurred > (let's say a button click). > This script outputs a stream of data and I would like to get the data in > cockpit and print it to the screen during the time the script is executed. > > What is the recommended way to do it using cockpit API ?
While you could use channels directly, the cockpit.spawn() API works well for this: https://cockpit-project.org/guide/latest/cockpit-spawn.html Something like this: process = cockpit.spawn(["/path/to/script"], err: "message"); process.fail(function(ex) { /* invoked if script fails */ }); process.stream(function(data) { /* invoked for every block of data script write to stdout */ }); Use this option to include stderr output in the streamed output: err: "out" If the script expects input or EOF on stdin, you can send it using: process.input("data"); or process.input(""); ... respectively. Hope this helps, Stef > > I saw the raw channel documentation, but found no examples / usage that > I can use. > > Please help, > Ido Rosenzwig > > > _______________________________________________ > cockpit-devel mailing list -- cockpit-devel@lists.fedorahosted.org > To unsubscribe send an email to cockpit-devel-le...@lists.fedorahosted.org > Fedora Code of Conduct: > https://docs.fedoraproject.org/en-US/project/code-of-conduct/ > List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines > List Archives: > https://lists.fedorahosted.org/archives/list/cockpit-devel@lists.fedorahosted.org > _______________________________________________ cockpit-devel mailing list -- cockpit-devel@lists.fedorahosted.org To unsubscribe send an email to cockpit-devel-le...@lists.fedorahosted.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedorahosted.org/archives/list/cockpit-devel@lists.fedorahosted.org