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
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
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
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
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',
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
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
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
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
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
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
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?
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
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
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'
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
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
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
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
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
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
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
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
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
>>> 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
>
> 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
\ \_/_\_/>
Thanks again for your kindly tips.
--
___
oo // \\
(_,\/ \_/ \ Xu, Qian
\ \_/_\_/> stanleyxu2005
/_/ \_\
--
http://mail.python.org/mailman/listinfo/python-list
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
> >>
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
[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 // \\
>> (_,\/ \_/ \
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
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
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 + '" "
33 matches
Mail list logo