Re: "fork and exit" needed?

2006-11-30 Thread Vincent Delporte
On Thu, 30 Nov 2006 10:18:24 -0500, "Mike C. Fletcher" <[EMAIL PROTECTED]> wrote: >which is how Linux knows what interpreter to use for the script. Thanks. That's what I found out after a bit more research. I didn't pay attention to this because it's not needed to run under Windows, and I was focu

Re: "fork and exit" needed?

2006-11-30 Thread Mike C. Fletcher
Vincent Delporte wrote: > On Thu, 30 Nov 2006 15:38:11 +0100, Vincent Delporte <[EMAIL PROTECTED]> > wrote: > >> Here's my Python rewrite: >> http://codecomplete.free.fr/asterisk/python_cid.txt >> First line of your script should be: #! /usr/bin/env python which is how Linux knows what in

Re: "fork and exit" needed?

2006-11-30 Thread Vincent Delporte
On Thu, 30 Nov 2006 15:48:53 +0100, Vincent Delporte <[EMAIL PROTECTED]> wrote: >-- Launched AGI Script /var/lib/asterisk/agi-bin/ncid.python.agi >Failed to execute '/var/lib/asterisk/agi-bin/ncid.python.agi': Exec >format error Stupid me :-/ Forgot the all-important #!/usr/bin/python Sorry

Re: "fork and exit" needed?

2006-11-30 Thread Vincent Delporte
On Thu, 30 Nov 2006 15:38:11 +0100, Vincent Delporte <[EMAIL PROTECTED]> wrote: >Here's my Python rewrite: >http://codecomplete.free.fr/asterisk/python_cid.txt More information. Here's what Asterisk says when I call in: *CLI> -- Executing LookupCIDName("SIP/fxo-0844e458", "") in new stack

Re: "fork and exit" needed?

2006-11-30 Thread Vincent Delporte
On Tue, 28 Nov 2006 04:30:09 -0600, Nick Craig-Wood <[EMAIL PROTECTED]> wrote: >I'm not sure how you do open stdout to /dev/null in python though! > >I suspect something like this... > > import posix > posix.close(1) > posix.open("/dev/null", posix.O_WRONLY) Thanks everyone, but no go :-/ Neith

Re: Really closing stdout (was: "fork and exit" needed?)

2006-11-29 Thread Nick Craig-Wood
Mitja Trampus <[EMAIL PROTECTED]> wrote: > Nick Craig-Wood wrote: > > I'm not sure how you do open stdout to /dev/null in python though! > > I suspect something like this... > > import posix > > posix.close(1) > > posix.open("/dev/null", posix.O_WRONLY) > > Yes, you're close enough... The

Re: "fork and exit" needed?

2006-11-28 Thread Vincent Delporte
On Tue, 28 Nov 2006 08:30:03 -0600, Nick Craig-Wood <[EMAIL PROTECTED]> wrote: >> import os,sys,time >> print "pre:", os.getpid() >> sys.stdout = open(os.devnull, 'w') >> print "post:", os.getpid() >> time.sleep(60) >> >> (Granted, I'm on WinXP; I also suspect the original stdout is still op

Re: Really closing stdout (was: "fork and exit" needed?)

2006-11-28 Thread Mitja Trampus
Nick Craig-Wood wrote: >>> open STDOUT, '>/dev/null'; >> sys.stdout = open(os.devnull, 'w') > $ ls -l /proc/32004/fd > total 4 > lrwx-- 1 ncw ncw 64 Nov 28 09:55 0 -> /dev/pts/17 > lrwx-- 1 ncw ncw 64 Nov 28 09:55 1 -> /dev/pts/17 > lrwx-- 1 ncw ncw 64 Nov 28 09:55 2 -> /dev/pts/17

Re: "fork and exit" needed?

2006-11-28 Thread Nick Craig-Wood
Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Tue, 28 Nov 2006 04:30:09 -0600, Nick Craig-Wood > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > > > > > If you run this > > > > import os,sys,time > > print os.getpid() > > sys.stdout = open(os.devnull, 'w') > > tim

Re: "fork and exit" needed?

2006-11-28 Thread Fredrik Lundh
Nick Craig-Wood wrote: > If you run this > > import os,sys,time > print os.getpid() > sys.stdout = open(os.devnull, 'w') > time.sleep(60) > > It prints its pid. and not only that, if you run print "world", print "hello" it prints "hello world" in the wrong order! --

Re: "fork and exit" needed?

2006-11-28 Thread Nick Craig-Wood
Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > In <[EMAIL PROTECTED]>, Vincent Delporte wrote: > > > Anyone knows if those lines are necessary, why, and what their > > alternative is in Python? > > > > open STDOUT, '>/dev/null'; > > sys.stdout = open(os.devnull, 'w') This doesn't hav

Re: "fork and exit" needed?

2006-11-28 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Vincent Delporte wrote: > Anyone knows if those lines are necessary, why, and what their > alternative is in Python? > > --- > open STDOUT, '>/dev/null'; sys.stdout = open(os.devnull, 'w') Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/li

Re: "fork and exit" needed?

2006-11-27 Thread [EMAIL PROTECTED]
Vincent Delporte wrote: > Hi > > I'm a Python newbie, and would like to rewrite this Perl scrip > to be run with the Asterisk PBX: > > http://www.voip-info.org/wiki/view/Asterisk+NetCID > > Anyone knows if those lines are necessary, why, and what their > alternative is in Python? > open STDO

"fork and exit" needed?

2006-11-27 Thread Vincent Delporte
Hi I'm a Python newbie, and would like to rewrite this Perl scrip to be run with the Asterisk PBX: http://www.voip-info.org/wiki/view/Asterisk+NetCID Anyone knows if those lines are necessary, why, and what their alternative is in Python? --- open STDOUT, '>/dev/null'; fork and exi