Re: Running python from pty without prompt

2016-12-14 Thread Michael Torrie
On 12/14/2016 09:29 PM, Samuel Williams wrote: > Here are some examples of different languages: > > https://github.com/ioquatix/script-runner/blob/master/examples/python-eot.py Okay so it looks like you're just opening a pipe to a subprocess and feeding it a script and input. So there's no pty

Re: Running python from pty without prompt

2016-12-14 Thread Samuel Williams
Here are some examples of different languages: https://github.com/ioquatix/script-runner/blob/master/examples/python-eot.py -- https://mail.python.org/mailman/listinfo/python-list

Re: Running python from pty without prompt

2016-12-14 Thread Steve D'Aprano
On Thu, 15 Dec 2016 01:28 am, Random832 wrote: > On Tue, Dec 13, 2016, at 19:10, Steve D'Aprano wrote: >> Can you show a simple demonstration of what you are doing? >> >> I'm having difficulty following this thread because I don't know >> what "script run on a tty" means. > > The question is

Re: Running python from pty without prompt

2016-12-14 Thread Random832
On Tue, Dec 13, 2016, at 19:20, Steve D'Aprano wrote: > sys.flags.interactive will tell you whether or not your script was > launched > with the -i flag. > > hasattr(sys, 'ps1') or hasattr(sys, 'ps2') will tell you if you are > running > in the REPL (interactive interpreter). The ps1 and ps2

Re: Running python from pty without prompt

2016-12-14 Thread Random832
On Tue, Dec 13, 2016, at 19:10, Steve D'Aprano wrote: > Can you show a simple demonstration of what you are doing? > > I'm having difficulty following this thread because I don't know > what "script run on a tty" means. The question is literally about the input/script being the tty and not

Re: Running python from pty without prompt

2016-12-13 Thread Ben Finney
Steve D'Aprano writes: > I thought that with the exception of scripts run from cron, any time > you run a script *or* in interactive mode, there is an associated tty. > Am I wrong? Any daemon will, by definition, have no controlling terminal. Other processes can

Re: Running python from pty without prompt

2016-12-13 Thread Michael Torrie
On 12/13/2016 05:10 PM, Steve D'Aprano wrote: > Can you show a simple demonstration of what you are doing? I think they want to run Python, perhaps remotely via ssh, and feed it both a script and input over standard-in (though a tty comes into this somehow and I'm not clear on that). Apparently

Re: Running python from pty without prompt

2016-12-13 Thread Steve D'Aprano
On Wed, 14 Dec 2016 04:48 am, Random832 wrote: > On Tue, Dec 13, 2016, at 11:01, Michael Torrie wrote: >> On 12/13/2016 05:39 AM, Samuel Williams wrote: >> > Michael, yes. >> > >> > FYI, I found out why this works. Pressing Ctrl-D flushes the input >> > buffer. If you do this on an empty line,

Re: Running python from pty without prompt

2016-12-13 Thread Steve D'Aprano
On Wed, 14 Dec 2016 09:24 am, Random832 wrote: > On Tue, Dec 13, 2016, at 17:09, Michael Torrie wrote: >> On 12/13/2016 10:48 AM, Random832 wrote: >> > The problem is there's currently no way to differentiate "interactive >> > mode" from "script run on a tty". >> > >> > You can get similar

Re: Running python from pty without prompt

2016-12-13 Thread Random832
On Tue, Dec 13, 2016, at 17:09, Michael Torrie wrote: > On 12/13/2016 10:48 AM, Random832 wrote: > > The problem is there's currently no way to differentiate "interactive > > mode" from "script run on a tty". > > > > You can get similar behavior with python -c "import > >

Re: Running python from pty without prompt

2016-12-13 Thread Michael Torrie
On 12/13/2016 10:48 AM, Random832 wrote: > The problem is there's currently no way to differentiate "interactive > mode" from "script run on a tty". > > You can get similar behavior with python -c "import > sys;exec(sys.stdin.read())" Are you sure? I can pipe scripts into Python and they run

Re: Running python from pty without prompt

2016-12-13 Thread Random832
On Tue, Dec 13, 2016, at 11:01, Michael Torrie wrote: > On 12/13/2016 05:39 AM, Samuel Williams wrote: > > Michael, yes. > > > > FYI, I found out why this works. Pressing Ctrl-D flushes the input > > buffer. If you do this on an empty line, it causes read(...) to return > > 0 which Ruby considers

Re: Running python from pty without prompt

2016-12-13 Thread Michael Torrie
On 12/13/2016 09:01 AM, Michael Torrie wrote: > On 12/13/2016 05:39 AM, Samuel Williams wrote: >> Michael, yes. >> >> FYI, I found out why this works. Pressing Ctrl-D flushes the input >> buffer. If you do this on an empty line, it causes read(...) to return >> 0 which Ruby considers end of input

Re: Running python from pty without prompt

2016-12-13 Thread Michael Torrie
On 12/13/2016 05:39 AM, Samuel Williams wrote: > Michael, yes. > > FYI, I found out why this works. Pressing Ctrl-D flushes the input > buffer. If you do this on an empty line, it causes read(...) to return > 0 which Ruby considers end of input for the script, but the pipe is > not closed.

Re: Running python from pty without prompt

2016-12-13 Thread Samuel Williams
Michael, yes. FYI, I found out why this works. Pressing Ctrl-D flushes the input buffer. If you do this on an empty line, it causes read(...) to return 0 which Ruby considers end of input for the script, but the pipe is not closed. -- https://mail.python.org/mailman/listinfo/python-list

Re: Running python from pty without prompt

2016-12-09 Thread Michael Torrie
On 12/09/2016 06:43 PM, Steve D'Aprano wrote: > On Sat, 10 Dec 2016 10:11 am, space.ship.travel...@gmail.com wrote: > >> Hello. >> >> I'm working on a script runner for Atom. >> >> https://github.com/ioquatix/script-runner >> >> We are trying to understand how to make python work well. I'll use a

Re: Running python from pty without prompt

2016-12-09 Thread Steve D'Aprano
On Sat, 10 Dec 2016 10:11 am, space.ship.travel...@gmail.com wrote: > Hello. > > I'm working on a script runner for Atom. > > https://github.com/ioquatix/script-runner > > We are trying to understand how to make python work well. I'll use a > comparison to the ruby executable because it's

Re: Running python from pty without prompt

2016-12-09 Thread Samuel Williams
Just in case it's not clear, this is running on a (virtual) PTY. -- https://mail.python.org/mailman/listinfo/python-list

Re: Running python from pty without prompt

2016-12-09 Thread Michael Torrie
On 12/09/2016 04:11 PM, space.ship.travel...@gmail.com wrote: > When you invoke `ruby` from a pty, you get no output (as opposed to > `irb`, interactive ruby [shell]). You can write a script to stdin, > and send Ctrl-D (EOT / 0x04). Then, ruby will execute the script. > stdin is not closed so

Re: Running python from pty without prompt

2016-12-09 Thread Michael Torrie
On 12/09/2016 04:11 PM, space.ship.travel...@gmail.com wrote: > Hello. > > I'm working on a script runner for Atom. > > https://github.com/ioquatix/script-runner > > We are trying to understand how to make python work well. I'll use a > comparison to the ruby executable because it's convenient

Running python from pty without prompt

2016-12-09 Thread space . ship . traveller
Hello. I'm working on a script runner for Atom. https://github.com/ioquatix/script-runner We are trying to understand how to make python work well. I'll use a comparison to the ruby executable because it's convenient to explain the problem. When you invoke `ruby` from a pty, you get no output