문제

Good Day all

I am trying to run the following command, but receive various error's I know I have the incorrect syntax or possibly using an incorrect method, would any one be kind enough to point in the correct direction.

Thanks for any assistance

the actual external program path as in windows command line or batch script would be.

"c:\Program Files\SQL Anywhere 11\Bin32\dbbackup.exe" -c "DSN=demo2suite;UID=dba;PWD=sql" -y "D:\Databases\demo2\LIVE\LIVE_BCK"

Python V3.3

my part of the code for this mini(newbie) project would be.

def BackupDatabase():
    try:
        os.system('c://Program Files//SQL Anywhere 11//Bin32//dbbackup.exe -c "DSN=amos2suite;UID=dba;PWD=sql" -y "D://Databases//AMOS2//LIVE//LIVE_BCK"')
    except OSError as e:
        WriteLog("error",e) 
도움이 되었습니까?

해결책

It's better to use subprocess module. Something like this:

import subprocess
subprocess.call(['c://Program Files//SQL Anywhere 11//Bin32//dbbackup.exe','-c',
'"DSN=demo2suite;UID=dba;PWD=sql"', '-y','"D://Databases//AMOS2//LIVE//LIVE_BCK"'])
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top