Welcome to MSDN Blogs Sign in | Join | Help

Redirecting output of Execute Process Task

Can you guess why this does not work?

A customer is trying to use the Execute Process Task to execute the preplog.exe application (Microsoft utility) and pass the following command-line arguments: inetsv1.log > inetsv1.txt.

Expected result: When the package runs, content in the inetsv1.log file is moved to the inetsv1.txt file.

If you need a hint: think about what code parses the redirections characters > and < and handles the redirection.

The redirections are not part of the OS, they are handled by command shell, under Windows this is usually CMD.EXE. Since SSIS just starts the application itself, all the arguments specified in the Arguments field are simply passed to the program. Neither SSIS nor the program you invoke handles the redirection, so this obviously can't work as expected.

How to make it work? Specify CMD.EXE as your executable and following line as arguments: /C YourApp AppArgs >OutputFile. The arguments are passed to CMD.EXE which runs your command and handles the input/output redirection.

An easier approach might be to put everything in a batch file (.CMD or .BAT) and run this batch file from Execute Process task.

Published Thursday, August 02, 2007 5:39 PM by michen
Filed under:

Comments

# re: Redirecting output of Execute Process Task

I am trying to invoke the PrepLog.exe from DTS via an Execute Process Task...the target is a .bat file...the interesting thing about PrepLog.exe is that the redirect seems to only work if the current path is set to the folder where the .Log source file resides and output file must also be created in that current directory...the PrepLog.exe does not accept fully qualified paths for the source and output files...only the location of the PrepLog.exe can be entered as a fully qualified path...

Wednesday, October 17, 2007 4:41 PM by William J. brown
New Comments to this post are disabled
 
Page view tracker