I am having a problem firing off a DOS app. To run a SQL 'SSIS' package, you use the following syntax:

C:>dtexec /f "PACKAGENAME.dtsx", the quotes are required.

I have tried os.system, os.execlp, os.execl and none of them seem to work.

os.system causes an error with 'dtexec' saying the package isn't prepared properly but ececuting it from the command line works.

using the os.exec* variants give me 'file cannot be found' in so.py ( func(fullname, *argrest))

when using the following

args = ['/f', '"IMPORT.dtsx"']
os.execlp('dtexec ',*args)

What is the proper way to run a command line program from inside Python?

The 'r' stands for raw, so the string is interpreted as it is, otherwise it must be:

import os

os.system(r'C:\\dtexec /f "PACKAGENAME.dtsx"')

because of the backslash interpreted as a escape.

You can also do:

import os

PACKAGENAME = 'something'
os.system(r'C:\\dtexec /f "%s.dtsx"' % PACKAGENAME)

Edited 6 Years Ago by Beat_Slayer: n/a

Although it does execute the app, I still get the error:

Error: 2010-08-11 12:02:38.35
Code: 0xC0011002
Source: {66582295-4DF7-407F-8411-C01C282F57A3}
Description: Failed to open package file "CSV_IMPORT.dtsx" due to error 0x800
C0006 "The system cannot locate the object specified.". This happens when loadi
ng a package and the file cannot be opened or loaded correctly into the XML docu
ment. This can be the result of either providing an incorrect file name was spec
ified when calling LoadPackage or the XML file was specified and has an incorrec
t format.

(sorry, I had to use the 'mark' in the dos window).

This is why I went the os.execlp route, I though maybe the command seassion created by system doesn't carry the exiting path along with it, hence the 'can't find the file specified'

You must provide full path to the dtsx file I believe.

import os

PACKAGENAME = 'something'
os.system(r'C:\\dtexec /f "c:\\folder\\%s.dtsx"' % PACKAGENAME)
This question has already been answered. Start a new discussion instead.