Re: Python without a tty

2011-10-03 Thread Nobody
On Mon, 03 Oct 2011 22:04:26 +1300, Gregory Ewing wrote: >> os.setsid() > > *This* is what's losing the tty. According to the Fine Man Page: > > DESCRIPTION > The setsid function creates a new session. The calling process is the > session leader of the new session, is the process g

Re: Python without a tty

2011-10-03 Thread Gregory Ewing
Hegedüs wrote: If you fork() your process, then it will also loose the tty... Um, no, fork() doesn't do that, as far as I know. os.setsid() *This* is what's losing the tty. According to the Fine Man Page: DESCRIPTION The setsid function creates a new session. The calling process is

Re: Python without a tty

2011-10-03 Thread Hegedüs , Ervin
hello, On Mon, Oct 03, 2011 at 09:28:27AM +0200, Hans Mulder wrote: > On 3/10/11 08:10:57, Hegedüs, Ervin wrote: > > > >If you fork() your process, then it will also loose the tty... > > Errhm, I suggest you check again. This cannot be true. > > >os.setsid() > > It is os.setsid() that makes yo

Re: Python without a tty

2011-10-03 Thread Hans Mulder
On 3/10/11 08:10:57, Hegedüs, Ervin wrote: hello, On Mon, Oct 03, 2011 at 04:37:43AM +, Steven D'Aprano wrote: I wanted to ensure that it would do the right thing when run without a tty, such as from a cron job. If you fork() your process, then it will also loose the tty... Errhm, I su

Re: Python without a tty

2011-10-02 Thread Hegedüs , Ervin
hello, On Mon, Oct 03, 2011 at 04:37:43AM +, Steven D'Aprano wrote: > > I wanted to ensure that it would do the right thing when run without a tty, > such as from a cron job. If you fork() your process, then it will also loose the tty... import os import sys try: pid = os.fork()

Re: Python without a tty

2011-10-02 Thread Hans Mulder
On 3/10/11 06:37:43, Steven D'Aprano wrote: On Fri, 30 Sep 2011 21:09:54 +0100, Nobody wrote: On Thu, 29 Sep 2011 11:53:12 +0200, Alain Ketterlin wrote: I have a Python script which I would like to test without a tty attached to the process. I could run it as a cron job, but is there an easie

Re: Python without a tty

2011-10-02 Thread Steven D'Aprano
On Fri, 30 Sep 2011 21:09:54 +0100, Nobody wrote: > On Thu, 29 Sep 2011 11:53:12 +0200, Alain Ketterlin wrote: > >>> I have a Python script which I would like to test without a tty >>> attached to the process. I could run it as a cron job, but is there an >>> easier way? [...] > I suspect that th

Re: Python without a tty

2011-09-30 Thread Hans Mulder
On 30/09/11 20:34:37, RJB wrote: You could try the old UNIX "nohup ...&" technique for running a process in the background (the&) with no HangUP if you log out: $ nohup python -c "import sys,os; print os.isatty(sys.stdout.fileno())"& appending output to nohup.out $ cat nohup.out False But that

Re: Python without a tty

2011-09-30 Thread Nobody
On Thu, 29 Sep 2011 11:53:12 +0200, Alain Ketterlin wrote: >> I have a Python script which I would like to test without a tty attached >> to the process. I could run it as a cron job, but is there an easier way? >> >> I am running Linux. > > Isn't os.setsid() what you're looking for? It makes th

Re: Python without a tty

2011-09-30 Thread RJB
On Sep 29, 3:52 am, Steven D'Aprano wrote: > Alain Ketterlin wrote: > > Steven D'Aprano writes: > > >> I have a Python script which I would like to test without a tty attached > >> to the process. I could run it as a cron job, but is there an easier way? > > >> I am running Linux. > > > Isn't os.

Re: Python without a tty

2011-09-29 Thread Ben Finney
ron writes: > On Sep 29, 5:21 am, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote: > > I have a Python script which I would like to test without a tty attached > > to the process. I could run it as a cron job, but is there an easier way? > > Have you tried GNU Screen? It let's you run pr

Re: Python without a tty

2011-09-29 Thread ron
On Sep 29, 5:21 am, Steven D'Aprano wrote: > I have a Python script which I would like to test without a tty attached > to the process. I could run it as a cron job, but is there an easier way? > > I am running Linux. > > -- > Steven Have you tried GNU Screen? It let's you run processes under vi

Re: Python without a tty

2011-09-29 Thread Bradley Cloete
> It doesn't appear so to me. > > [steve@sylar ~]$ tty > /dev/pts/16 > [steve@sylar ~]$ setsid tty > /dev/pts/16 > > [steve@sylar ~]$ python -c "import sys,os; print > os.isatty(sys.stdout.fileno())" > True > [steve@sylar ~]$ setsid python -c "import sys,os; print > os.isatty(sys.stdout.fileno())"

Re: Python without a tty

2011-09-29 Thread Martin P. Hellwig
On 29/09/2011 10:21, Steven D'Aprano wrote: I have a Python script which I would like to test without a tty attached to the process. I could run it as a cron job, but is there an easier way? I am running Linux. Well you could double fork and drop the parent, that would lose the tty which is

Re: Python without a tty

2011-09-29 Thread Roy Smith
In article <4e84388c$0$29965$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > I have a Python script which I would like to test without a tty attached > to the process. I could run it as a cron job, but is there an easier way? I'm not sure what you mean by "without a tty attached

Re: Python without a tty

2011-09-29 Thread Ben Finney
Steven D'Aprano writes: > I have a Python script which I would like to test without a tty > attached to the process. I could run it as a cron job, but is there an > easier way? > > I am running Linux. You could crib from the ‘python-daemon’ library implementation http://pypi.python.org/pypi/pyth

Re: Python without a tty

2011-09-29 Thread Alain Ketterlin
Steven D'Aprano writes: > Alain Ketterlin wrote: >>> I have a Python script which I would like to test without a tty attached >>> to the process. I could run it as a cron job, but is there an easier way? >> Isn't os.setsid() what you're looking for?[...] > It doesn't appear so to me. [...] > [

Re: Python without a tty

2011-09-29 Thread Hans Mulder
On 29/09/11 12:52:22, Steven D'Aprano wrote: [steve@sylar ~]$ python -c "import sys,os; print os.isatty(sys.stdout.fileno())" True > If I run the same Python command (without the setsid) as a cron job, I get False emailed to me. That's the effect I'm looking for. In that case, all you need t

Re: Python without a tty

2011-09-29 Thread Hans Mulder
On 29/09/11 11:21:16, Steven D'Aprano wrote: I have a Python script which I would like to test without a tty attached to the process. I could run it as a cron job, but is there an easier way? There is module on Pypi called python-daemon; it implements PEP-3143. This module detaches the process

Re: Python without a tty

2011-09-29 Thread Steven D'Aprano
Alain Ketterlin wrote: > Steven D'Aprano writes: > >> I have a Python script which I would like to test without a tty attached >> to the process. I could run it as a cron job, but is there an easier way? >> >> I am running Linux. > > Isn't os.setsid() what you're looking for? It makes the calli

Re: Python without a tty

2011-09-29 Thread Alain Ketterlin
Steven D'Aprano writes: > I have a Python script which I would like to test without a tty attached > to the process. I could run it as a cron job, but is there an easier way? > > I am running Linux. Isn't os.setsid() what you're looking for? It makes the calling process have no controlling term

Re: Python without a tty

2011-09-29 Thread Thomas Jollans
On 29/09/11 11:21, Steven D'Aprano wrote: > I have a Python script which I would like to test without a tty attached > to the process. I could run it as a cron job, but is there an easier way? > > I am running Linux. > ./program /dev/null 2>&1 -- http://mail.python.org/mailman/listinfo/python

Python without a tty

2011-09-29 Thread Steven D'Aprano
I have a Python script which I would like to test without a tty attached to the process. I could run it as a cron job, but is there an easier way? I am running Linux. -- Steven -- http://mail.python.org/mailman/listinfo/python-list