Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: how to call shell?

Reply
Thread Tools

Re: how to call shell?

 
 
Albert Hopkins
Guest
Posts: n/a
 
      02-12-2013


On Tue, Feb 12, 2013, at 12:12 AM, contro opinion wrote:
> >>> import os
> >>> os.system("i=3")

> 0
> >>> os.system("echo $i")

>
> 0
> >>>

> why i can't get the value of i ?


Whenever you call os.system, a new shell is created and the command is
run, system() then waits for the command to complete.
You don't see i because your two system() calls are in two different
processes:

python> import os
python> os.system('echo $$')
24294
0
python> os.system('echo $$')
24295
0

However, ths (e.g.) would work:

python> os.system('i=3; echo $i')
3
0

HTH,
-a
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Call Manager limit call duration nazgulero Cisco 0 10-25-2005 06:58 AM
How to make landline call to another landline then out call long distance? jt VOIP 6 01-30-2005 03:57 AM
RMI: remote call or local call Buu Nguyen Java 5 09-17-2004 08:05 AM
help: need to call call web service from java bill sandner Java 1 07-01-2004 02:57 PM



Advertisments