Re: call shell from python

2013-02-12 Thread spilcm
On Tuesday, February 12, 2013 6:13:38 AM UTC+1, contro opinion wrote:
> >>> import os
> >>> os.system("i=3")
> 0
> >>> os.system("echo $i")
> 
> 
> 0
> how can i get the value of  i?

You may want to take a look at the pexcpect module : 
http://www.noah.org/wiki/pexpect
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: call shell from python

2013-02-11 Thread Chris Rebert
On Mon, Feb 11, 2013 at 9:13 PM, contro opinion  wrote:
 import os
 os.system("i=3")
> 0
 os.system("echo $i")
>
> 0
> how can i get the value of  i?

Your example is too heavily contrived for me to give a much more
specific/useful answer than "use the `subprocess` module":
http://docs.python.org/2/library/subprocess.html#using-the-subprocess-module

Of course, if all you want to do is manipulate environment variables,
then there's `os.environ`:
http://docs.python.org/2/library/os.html#os.environ

Good luck, my pseudonymous contrarian compadre.
– Chris
-- 
http://mail.python.org/mailman/listinfo/python-list