interact with command-line tools from the notebook

71 views
Skip to first unread message

Denis Akhiyarov

unread,
May 16, 2017, 8:22:18 AM5/16/17
to Project Jupyter

Is there any way I can interact with command-line tools from the notebook? For example scriptcs embeds itself in cmd as a REPL.

In the notebook it is not interactive. In fact I cannot even kill the scriptcs process () when it is called in the notebook:

taskkill /f /im scriptcs*
ERROR: The process "scriptcs*" not found.






Thomas Kluyver

unread,
May 16, 2017, 11:50:33 AM5/16/17
to Project Jupyter
There's nothing automatic, because we can't tell when a process is waiting for input. If you know what the prompt looks like, you may be able to use something like pexpect.replwrap to run it - though I don't know if that will work on Windows.

--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+unsubscribe@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/5bbeff4d-25f3-4e92-86aa-31a6d3c3636d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Denis Akhiyarov

unread,
May 16, 2017, 12:53:56 PM5/16/17
to Project Jupyter
Ok, I understood that this is difficult after trying out 2 options :) pexpect support on Windows is partial and experimental, hence I will not even try this. Anyway working with command-line tools right from ipython/jupyter would be very handy, especially for presentations!

--
You received this message because you are subscribed to a topic in the Google Groups "Project Jupyter" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jupyter/linMSNXHiEs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jupyter+unsubscribe@googlegroups.com.

To post to this group, send email to jup...@googlegroups.com.

Lawrence D’Oliveiro

unread,
Jun 9, 2017, 7:12:09 PM6/9/17
to Project Jupyter
On Wednesday, May 17, 2017 at 3:50:33 AM UTC+12, takowl wrote:
There's nothing automatic, because we can't tell when a process is waiting for input.

Isn’t that what select is for?

Thomas Kluyver

unread,
Jun 12, 2017, 7:27:08 AM6/12/17
to Project Jupyter
On 10 June 2017 at 00:12, Lawrence D’Oliveiro <lawren...@gmail.com> wrote:
Isn’t that what select is for?

select() will tell you whether there's space in a buffer to write to for a given fd. But you can write to the master side of a pty regardless of what the process in it is doing - type 'sleep 10' into bash, and then try typing letters while it is doing nothing. We can't tell whether the process on the other side of the pty is actually waiting for input, only that the input buffer isn't full. That's why tools like pexpect can be used to look for know patterns like 'password: '.

Lawrence D’Oliveiro

unread,
Jun 12, 2017, 6:32:35 PM6/12/17
to Project Jupyter
On Monday, June 12, 2017 at 11:27:08 PM UTC+12, takowl wrote:
On 10 June 2017 at 00:12, Lawrence D’Oliveiro <lawren...@gmail.com> wrote:
Isn’t that what select is for?

select() will tell you whether there's space in a buffer to write to for a given fd. But you can write to the master side of a pty regardless of what the process in it is doing ...

Ah. I knew there was a good reason why command-line tools should be able to operate without having to do interactive I/O ...
Reply all
Reply to author
Forward
0 new messages