Re: os.system() question

2009-10-19 Thread Benjamin Kaplan
On Mon, Oct 19, 2009 at 2:14 PM, Bryan Irvine wrote: > I'm a python n00b and so pardon me in advance if this is really stupid > question. > > I have my suspicions but why does the following not work the way I'm > anticipating it will? > > (python 2.4.4) > import os if (os.system('echo t

Re: os.system() question

2009-10-19 Thread Chris Rebert
On Mon, Oct 19, 2009 at 11:14 AM, Bryan Irvine wrote: > I'm a python n00b and so pardon me in advance if this is really stupid > question. > > I have my suspicions but why does the following not work the way I'm > anticipating it will? > > (python 2.4.4) > import os if (os.system('echo

Re: os.system() question

2009-10-19 Thread Ethan Furman
Bryan Irvine wrote: I'm a python n00b and so pardon me in advance if this is really stupid question. I have my suspicions but why does the following not work the way I'm anticipating it will? (python 2.4.4) import os if (os.system('echo test')): ...print 'success' ... else: ...prin

os.system() question

2009-10-19 Thread Bryan Irvine
I'm a python n00b and so pardon me in advance if this is really stupid question. I have my suspicions but why does the following not work the way I'm anticipating it will? (python 2.4.4) >>> import os >>> if (os.system('echo test')): ...print 'success' ... else: ...print 'failed' ... tes

Re: os.system question

2008-08-13 Thread Fredrik Lundh
Kevin Walzer wrote: I'm also skeptical of the value of subprocess, at least as a complete replacement for os.popen (the original version): it currently provides no way to set a 'non-blocking' mode. I make heavy use of this kind of call in my code: self.file = os.popen('do stuff here'), 'r',

Re: os.system question

2008-08-13 Thread Kevin Walzer
Fredrik Lundh wrote: not talking for the 3.X developers here, but os.popen is a binding to the POSIX popen function, so I'm not sure it makes that much sense to actually deprecate it. the os.popen[234], popen2, and commands stuff are different -- they're a a series of attempts to provide m

Re: os.system question

2008-08-13 Thread Wojtek Walczak
Dnia Wed, 13 Aug 2008 22:03:49 +0200, Fredrik Lundh napisa�(a): > not talking for the 3.X developers here, but os.popen is a binding to > the POSIX popen function, so I'm not sure it makes that much sense to > actually deprecate it. > > the os.popen[234], popen2, and commands stuff are different

Re: os.system question

2008-08-13 Thread Mike Driscoll
On Aug 13, 3:03 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Mike Driscoll wrote: > >> I note 3.0 runs os.popen without complaint (and had thought to mention > >> that in my previous).  Right now I'm wondering whether I should > >> install the beta 2.6 to see whether Wotjek is pulling our leg or

Re: os.system question

2008-08-13 Thread Fredrik Lundh
Mike Driscoll wrote: I note 3.0 runs os.popen without complaint (and had thought to mention that in my previous). Right now I'm wondering whether I should install the beta 2.6 to see whether Wotjek is pulling our leg or not. :) That was the wording I was referring to. Now that I re-read it, I

Re: os.system question

2008-08-13 Thread Mike Driscoll
On Aug 13, 1:38 am, Asun Friere <[EMAIL PROTECTED]> wrote: > On Aug 13, 8:58 am, Steven D'Aprano <[EMAIL PROTECTED] > > cybersource.com.au> wrote: > > On Mon, 11 Aug 2008 19:28:13 -0700, Asun Friere wrote: > > > > but if I was in a hurry to find out who I was I would be tempted still > > > to use t

Re: os.system question

2008-08-13 Thread Wojtek Walczak
Dnia Tue, 12 Aug 2008 23:38:56 -0700 (PDT), Asun Friere napisa�(a): > I note 3.0 runs os.popen without complaint (and had thought to mention > that in my previous). Right now I'm wondering whether I should > install the beta 2.6 to see whether Wotjek is pulling our leg or > not. :) :) Checked it

Re: os.system question

2008-08-12 Thread Asun Friere
On Aug 13, 8:58 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Mon, 11 Aug 2008 19:28:13 -0700, Asun Friere wrote: > > > but if I was in a hurry to find out who I was I would be tempted still > > to use the deprecated "os.popen('whoami').read()". > > Is it really deprecated?

Re: os.system question

2008-08-12 Thread Wojtek Walczak
Dnia 12 Aug 2008 22:58:22 GMT, Steven D'Aprano napisa�(a): >> but if I was in a hurry to find out who I was I would be tempted still >> to use the deprecated "os.popen('whoami').read()". > > Is it really deprecated? Since when? I'm using Python 2.5 and it doesn't > raise any warnings or mention a

Re: os.system question

2008-08-12 Thread Steven D'Aprano
On Mon, 11 Aug 2008 19:28:13 -0700, Asun Friere wrote: > Something like this should work, > from subprocess import Popen, PIPE me = Popen('whoami', stdout=PIPE, shell=True).stdout.read() > > but if I was in a hurry to find out who I was I would be tempted still > to use the deprecated

Re: os.system question

2008-08-12 Thread Steven D'Aprano
On Tue, 12 Aug 2008 14:42:28 -0700, norseman wrote: > Can we take a moment and look at what is happening here? > > Python developers are creating an unwanted item! > > Let's take a good look: > > 1) import os 9 > 2) name=os.popen('whoami'

Re: os.system question

2008-08-12 Thread norseman
Asun Friere wrote: On Aug 8, 6:07 am, Mike Driscoll <[EMAIL PROTECTED]> wrote: On Aug 6, 8:07 pm, Kevin Walzer <[EMAIL PROTECTED]> wrote: >>> import os >>> foo = os.system('whoami') kevin >>> print foo 0 >>> The standard output of the system command 'whoami' is my login name. Yet the value

Re: os.system question

2008-08-11 Thread Asun Friere
On Aug 8, 6:07 am, Mike Driscoll <[EMAIL PROTECTED]> wrote: > On Aug 6, 8:07 pm, Kevin Walzer <[EMAIL PROTECTED]> wrote: > > > >>> import os > > >>> foo = os.system('whoami') > > kevin > > >>> print foo > > 0 > > >>> > > > The standard output of the system command 'whoami' is my login name. Yet

Re: os.system question

2008-08-11 Thread Brad
Kevin Walzer wrote: >>> import os >>> foo = os.system('whoami') kevin >>> print foo 0 >>> The standard output of the system command 'whoami' is my login name. Yet the value of the 'foo' object is '0,' not 'kevin.' How can I get the value of 'kevin' associated with foo? Hi Kevin, check

Re: os.system question

2008-08-07 Thread Mike Driscoll
On Aug 6, 8:07 pm, Kevin Walzer <[EMAIL PROTECTED]> wrote: >  >>> import os >  >>> foo = os.system('whoami') > kevin >  >>> print foo > 0 >  >>> > > The standard output of the system command 'whoami' is my login name. Yet > the value of the 'foo' object is '0,' not 'kevin.' How can I get the > valu

Re: os.system question

2008-08-07 Thread Eric Wertman
In your case you could also use the os.environ dictionary: import os print os.environ['USER'] -- http://mail.python.org/mailman/listinfo/python-list

Re: os.system question

2008-08-07 Thread Kevin Walzer
SamG wrote: Why dont you try commands module instead Thank you! That was just what I needed. -- Kevin Walzer Code by Kevin http://www.codebykevin.com -- http://mail.python.org/mailman/listinfo/python-list

Re: os.system question

2008-08-07 Thread SamG
On Aug 7, 6:07 am, Kevin Walzer <[EMAIL PROTECTED]> wrote: >  >>> import os >  >>> foo = os.system('whoami') > kevin >  >>> print foo > 0 >  >>> > > The standard output of the system command 'whoami' is my login name. Yet > the value of the 'foo' object is '0,' not 'kevin.' How can I get the > valu

Re: os.system question

2008-08-06 Thread Larry Wang
os.system() simply executes the command in a subshell, and returns the command's exit status which in your case is '0'. If you need to capture the stdout, stderr, etc. stuff, subprocess module is preferred which offers more powerful functionalities over os.system(). Nessus "Kevin Walzer" <[EM

Re: os.system question

2008-08-06 Thread Steven D'Aprano
On Wed, 06 Aug 2008 21:07:40 -0400, Kevin Walzer wrote: import os > >>> foo = os.system('whoami') > kevin > >>> print foo > 0 > >>> > >>> > The standard output of the system command 'whoami' is my login name. Yet > the value of the 'foo' object is '0,' not 'kevin.' How can I get the > val

os.system question

2008-08-06 Thread Kevin Walzer
>>> import os >>> foo = os.system('whoami') kevin >>> print foo 0 >>> The standard output of the system command 'whoami' is my login name. Yet the value of the 'foo' object is '0,' not 'kevin.' How can I get the value of 'kevin' associated with foo? -- Kevin Walzer Code by Kevin http://www.co

Re: os.system question

2007-12-28 Thread stanleyxu
> > import subprocess > > output = subprocess.Popen('MD "' + new_folder + '"', shell=True, > stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0] > print output > > > Carl Banks Thanks Carl, it works ^^) -- ___ oo // \\ (_,\/ \_/ \ Xu, Qian \ \_/_\_/>

Re: os.system question

2007-12-28 Thread stanleyxu
Thanks again for your kindly tips. -- ___ oo // \\ (_,\/ \_/ \ Xu, Qian \ \_/_\_/> stanleyxu2005 /_/ \_\ -- http://mail.python.org/mailman/listinfo/python-list

Re: os.system question

2007-12-28 Thread kyosohma
On Dec 28, 1:32 pm, stanleyxu <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > On Dec 28, 12:57 pm, stanleyxu <[EMAIL PROTECTED]> wrote: > >> To note this problem occurs when debugging script in IDLE editor. > >> When I double click on my_script.py, all outputs will be printed in one > >>

Re: os.system question

2007-12-28 Thread Carl Banks
On Dec 28, 1:52 pm, stanleyxu <[EMAIL PROTECTED]> wrote: > Hi All, > > I am porting Perl script to Python script. Everything works fines until > calling os.system(). > > In my script, a number of DOS-commands will be executed. >for new_folder, old_folder in folder_array: >os.system('MD

Re: os.system question

2007-12-28 Thread stanleyxu
[EMAIL PROTECTED] wrote: > On Dec 28, 12:57 pm, stanleyxu <[EMAIL PROTECTED]> wrote: >> To note this problem occurs when debugging script in IDLE editor. >> When I double click on my_script.py, all outputs will be printed in one >> console. >> >> -- >> ___ >>oo // \\ >> (_,\/ \_/ \

Re: os.system question

2007-12-28 Thread kyosohma
On Dec 28, 12:57 pm, stanleyxu <[EMAIL PROTECTED]> wrote: > To note this problem occurs when debugging script in IDLE editor. > When I double click on my_script.py, all outputs will be printed in one > console. > > -- > ___ >oo // \\ > (_,\/ \_/ \ Xu, Qian > \ \_/_\_/> s

Re: os.system question

2007-12-28 Thread stanleyxu
To note this problem occurs when debugging script in IDLE editor. When I double click on my_script.py, all outputs will be printed in one console. -- ___ oo // \\ (_,\/ \_/ \ Xu, Qian \ \_/_\_/> stanleyxu2005 /_/ \_\ -- http://mail.python.org/mailman/listinfo/py

os.system question

2007-12-28 Thread stanleyxu
Hi All, I am porting Perl script to Python script. Everything works fines until calling os.system(). In my script, a number of DOS-commands will be executed. for new_folder, old_folder in folder_array: os.system('MD "' + new_folder + '"'); os.system('XCOPY "' + old_folder + '" "