Issue 1279: os.system() oddity under Windows XP SP2 (original) (raw)

Issue1279

Created on 2007-10-15 13:12 by pythonmeister, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg56439 - (view) Author: Stefan Sonnenberg-Carstens (pythonmeister) Date: 2007-10-15 13:12
When doing such os.system("a command wich writes a outfile") f = open("the file the command before wrote") the file is empty. If I do this: os.popen("a command wich writes a outfile") f = open("the file the command before wrote") everything is fine
msg56440 - (view) Author: Tim Golden (tim.golden) * (Python committer) Date: 2007-10-15 13:44
Not, apparently, on my (XP SP2) box: Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> os.system ("""python -c "f=open ('temp.txt','w');f.write('hello');f.close ()"""); print open ("temp.txt").read () 0 hello >>> Perhaps you could provide a runnable piece of code which demonstrates the problem?
msg59183 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2008-01-03 23:58
It might happen when the program hasn't terminated yet. You have to make sure the program has terminated before you read the file. Subprocess and its wait() should help.
History
Date User Action Args
2022-04-11 14:56:27 admin set github: 45620
2008-01-03 23:58:40 christian.heimes set status: open -> closedresolution: wont fixmessages: + nosy: + christian.heimes
2007-10-15 13:44:25 tim.golden set nosy: + tim.goldenmessages: +
2007-10-15 13:12:56 pythonmeister create