Getting errors from popen in Windows

ChrisH secun at yahoo.com
Mon Oct 25 11:51:10 EDT 2004


Is there a way in python to run a DOS command and have it return any errors that occur? I've 
tried some of the different versions of peopen as well as the code listed below and none of 
them give me the error that is displayed when I run the command from a prompt.

(Python 2.3, win32all, Windows NT/2K/XP)



strExec = 'copy "z:\MS Exchange Settings.NK2" "%USERPROFILE%\Application Data\Microsoft
\Outlook\"'
    outdata=''
    proc = os.popen(strExec)
    while 1:
        line = proc.readline()
        if line:
            print line
            outdata=outdata+line
        else:
            break 


Thanks for the help,
Chris



More information about the Python-list mailing list