ipython: Can I provide input to a shell command

前端 未结 4 1611
广开言路
广开言路 2021-01-18 16:12

Can I execute a shell command that requires input in ipython and/or an ipython notebook?

When I execute such a command, I see it\'s prompt, but no apparent way to p

4条回答
  •  梦谈多话
    2021-01-18 16:49

    Was just looking for this and my wee face dropped when I saw it was a bit of an issue. Thought I would just post my solution in case it is usefull to anyone else.

    Basically I was looking for a way to send sudo commands through the notebook, probably not very wise but I needed it for what I was doing. And i couldn't get a prompt for the password. So decided to use a x-terminal and sending the command through to the terminal. You don't get any feed back but may be due to not hooking to the IO on the way back. Here is what i used in the notebook:

    In [1] !xterm -e sudo mount -o loop system.img /system/

    I'm using linux but i would expect !cmd for windows might do the trick too

提交回复
热议问题