os.system and wget
John Hunter
jdhunter at nitace.bsd.uchicago.edu
Thu Nov 14 17:36:26 EST 2002
>>>>> "Joerg" == Joerg Woelke <dvass at felis.uni-freiburg.de> writes:
>> h = os.popen('wget -q -O foo1.txt http://foo.html') h.close()
Joerg> What for, if you don't do anything (read/write) with the
Joerg> pipe? That's what os.system is for.
Not a good reason -- just a guess on my part. I tried the example
code with popen and it worked (for me), and thought that perhaps
calling the close method before trying to open the file would insure
that the system process had completed before he tried to read the
resultant file.
It appears that the OP has something funny going on with his system,
since both the popen and system approaches work fine on my system....
>> import os
>>> os.unlink('test1.dat')
>>> os.unlink('test2.dat')
>>> os.system('wget -q -O test1.dat html://foo.html')
256
>>> print 'test1: ', os.path.exists('test1.dat')
test1: 1
>>> h = os.popen('wget -q -O test2.dat html://foo.html')
>>> h.close()
256
>>> print 'test2: ', os.path.exists('test2.dat')
test2: 1
John Hunter
More information about the Python-list
mailing list