At 12:24 PM 5/12/2005, Danny Yoo wrote:
######
' 1 2 11\n'
######
######
import popen2
process = popen2.Popen3(['wc'])
process.tochild.write("hello\nworld")
process.tochild.close()
process.fromchild.read()
process = popen2.Popen3(['wc'])
process.tochild.write("hello\nworld")
process.tochild.close()
process.fromchild.read()
process.fromchild.close()
process.wait()
process.wait()
little funky if it doesn't.
For example, modifying the model to have clamdscan exit with 0:
######
import popen2
process = popen2.Popen3(['clamdscan','ham.test'])
process.tochild.close()
process.fromchild.read()
process = popen2.Popen3(['clamdscan','ham.test'])
process.tochild.close()
process.fromchild.read()
0\nTime: 0.098 sec (0 m 0 s)\n'
process.fromchild.close()
process.wait()
process.wait()
Now rewrite it to return an exit code of 1:
######
import popen2
process = popen2.Popen3(['clamdscan','eicar.test'])
process.tochild.write("hello\nworld")
process.tochild.close()
process.fromchild.read()
process = popen2.Popen3(['clamdscan','eicar.test'])
process.tochild.write("hello\nworld")
process.tochild.close()
process.fromchild.read()
-----------\nInfected files: 1\nTime: 0.043 sec (0 m 0 s)\n'
process.fromchild.close()
process.wait()
process.wait()
######
Now for a exit code of 2:
######
import popen2
process = popen2.Popen3(['clamdscan','nonexistent.test'])
process.tochild.close()
process.fromchild.read()
process = popen2.Popen3(['clamdscan','nonexistent.test'])
process.tochild.close()
process.fromchild.read()
(0 m 0 s)\n'
process.fromchild.close()
process.wait()
process.wait()
######
In my fiirst example, clamdscan should return 1 when the EICAR string is
found -- process.wait() gets 256 instead.
In the second, clamdscan returns 2 if an error occurs, such as trying to
scan a non-existent file, but 512 is returned.
No doubt there is a reason why the exit code is getting multiplied by
256... ??? My search has not enlightened me, however.
Jeff
* * * * * * *
Jeffrey Rice || jeffrice at finity.org || www.finity.org