I'm trying to write a "module" to a larger program.  This module eventually
needs to reference a config file with setup information in it, but I'm not
there yet.  I'm using the subprocess module to run an external antivirus
program and trying to get the output written to a log file, but I keep
getting a weird return.  My code is listed below.  I'm a noob to Python so
I'm not sure if this is a windows specific issue or not, but I'm programming
on windows and more then likely what I'm working on won't be on anything
other then a windows machine.  I'm also writing my code for 3.1 if that
makes any difference.

# Pass target path to scanners command line and write output to a file
# Currently "scan" only targets the McAfee Command Line Scanner
print() 
print ("Begining scan of " + target)
print()
scan = "scan /all " + target
s = subprocess.Popen(scan,
                     stdout=subprocess.PIPE)
out = s.communicate()[0]
chgout = str(out)
s.wait()
scanlog.write(chgout)
scanlog.close
"
If I change my stdout in s subprocess to None then everything gets written
to the terminal as if I had just run the program straight from the command
line, but when I try piping it to my file "scanlog" then literally the only
return I get in the file is '' or two single quotes.  I've even tried piping
the output and then printing it instead of writing it to a file and I get
the same result.  I've experimented with standard windows command line
commands and using the same syntax was able to pipe directory listings and
other things to my file.  Any ideas what I'm missing here?  Thanks in
advance

Chris Chapman

_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to