cling icon indicating copy to clipboard operation
cling copied to clipboard

Shell command

Open gouarin opened this issue 6 years ago • 3 comments

As you know, I work with @SylvainCorlay and @JohanMabille on https://github.com/QuantStack/xeus-cling to have a fully kernel C++ based on xeus and cling.

We have a first version which works in Jupyter. To have the cout and cerr of cling, we use a redirection of the Interpreter output.

Unfortunately, the shell command (.!) used in cling calls the std::system function. So it is not possible for us to keep the output of the shell command.

A hack could be to save the result in a file with the redirection > tmp_file and then print the output in cling::outs().

gouarin avatar Jul 18 '17 09:07 gouarin

@vgvassilev, do you have any idea of how to do that ? I have tried with the construction of temporary files but it is too complicated with C++. The only solution that I found is to mix with C programming using popen ...

gouarin avatar Jul 23 '17 10:07 gouarin

I am not aware of any other way to do it. I think redirecting to cling::outs() and cling::errs() makes sense. Could you submit a PR once you have it?

vgvassilev avatar Jul 23 '17 10:07 vgvassilev

Ok. I will try to write something that works with popen.

gouarin avatar Jul 23 '17 10:07 gouarin