SSIS 2008 adding extra quote in Execute Process task

  • I have an Execute Process task in my package. It is running a mysql command I use a few variables to build the command.

    1. [User::MySql] = \\crsddvcp01cru.d2-tdbfg.com\JOBS\SANScreen\mysql.exe

    2. [User::SanScreen] = "C:\Users\Redirection\brittg2\Documents\LINQPad Queries\SanScreen_CapacityCurrentFact.sql"

    I put it together with two expressions:

    1. Executable = @[User::MySql]

    2. Arguments = "-pxxx -uxxx --host=myhost.mydomain.com <" + @[User::SanScreen] + " -B >" + @[User::OutPut] + " 2> C:\\Users\\brittg2\\Temp\\out.err"

    However, the execute process task fails. Upon closer inspection, I see that SSIS has added an extra double quote, which is in fact the problem. SSIS constructs and tries to execute this:

    [Execute Process Task] Error: In Executing "\\crsddvcp01cru.d2-tdbfg.com\JOBS\SANScreen\mysql.exe" "-pxxx -uxxx --host=myhost.mydomain.com <"C:\Users\Redirection\brittg2\Documents\LINQPad Queries\SanScreen_CapacityCurrentFact.sql" -B >C:\Users\brittg2\Temp\temp.txt 2> C:\Users\brittg2\Temp\out.err" at "C:\Users\brittg2\Temp", The process exit code was "1" while the expected was "0".

    which fails due to the extra quote just before -pxxx. If I remove the extra quote, I can run the command correctly without error.

    So...

    1. What is the cause of the extra double quote?

    2. How can I get around the problem?

    Gerald Britton, Pluralsight courses

  • What if you create another variable @args that contains "-pxxx -uxxx --host=myhost.mydomain.com <" + @[User::SanScreen] + " -B >" + @[User::OutPut] + " 2> C:\\Users\\brittg2\\Temp\\out.err" as an expression and just use this variable in the Execute Process Task?

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Tried that. Same result

    Gerald Britton, Pluralsight courses

  • Found the answer. This is a feature, not a bug! SSIS always encloses the entire argument string in double quotes. This makes it useless for (directly) running Robocoy, Powershell and a host of other commands.

    There is a workaround:

    set the executable to c:\windows\system32\cmd.exe

    set the arguments to:

    "/c " + @[User::MyCmd] + " " + @[User::MyOpts]

    Gerald Britton, Pluralsight courses

  • Good to know. Thanks for posting the solution.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply