SSIS: Mismatched quotes error - ssis

I am trying to get this DTEXEC statement to work:
DTExec /REP E /f Congrat.dtsx
/CONNECTION AcadProfDW;"\"Data Source=###########;User ID=######;
Password=##########;Initial Catalog=AcadProfDW;Provider=SQLNCLI11.1;
Persist Security Info=True;Auto Translate=False;\""
/Set \Package.Variables[Project::CsvInputFilePath].Properties[Value];
"d:\directory\"
I get this error:
The argument "\Package.Variables[Project::CsvInputFilePath].Properties[Value];d:\directory " has mismatched quotes.
I've tried placing a quote before '\Package', adding an extra quote at the end, around the semicolon, and myriad other variations and I keep getting that error. What am I missing?

You should write your /Set param as follows:
/Set \Package.Variables[Project::CsvInputFilePath].Properties[Value];
"d:\directory\\"
or
"/Set \Package.Variables[Project::CsvInputFilePath].Properties[Value];
d:\directory\\"
There is an SO question on this, here is the answer - https://stackoverflow.com/a/3348557

Related

How to add json object to arguments

I'm trying to add json object to my powershell script using cmd. My issue, is that I receive the string but without any quotes.
My script.ps1:
Write-Host ($args[0] | Format-Table | Out-String)
My command line :
C:\path\to\powershell.exe ./script.ps1 '{"key1":"val1","all":[{"key2":"val2","key3":"val3","key4":["val5","val6"]},{"key5":"val7","key6":"val8","key7":["val9","val10"]}],"key8":0}'
Result :
{key1:val1,all:[{key2:val2,key3:val3,key4:[val5,val6]},{key5:val7,key6:val8,key7:[val9,val10]}],key8:0}
How can I get my json with quotes ?
When using PowerShell's CLI, unescaped " on the command line are removed during command-line parsing, and only then is the result interpreted as PowerShell code to execute (due to the (implied) use of the -Command / -c parameter).[1]
You have two options:
As Compo notes and demonstrates in his comment, escaping all " chars. as \" would work - the escaping ensures that they are retained, in unescaped form, and therefore become part of the PowerShell code to execute.
If you want to avoid escaping, provide the text via the pipeline (stdin):
echo {"key1":"val1","all":[{"key2":"val2","key3":"val3","key4":["val5","val6"]},{"key5":"val7","key6":"val8","key7":["val9","val10"]}],"key8":0}| powershell.exe -c ./script.ps1 $input
Note the absence of a space before |, as such spaces would otherwise become part of the input.
In the PowerShell command, the piped-in text is accessed via the automatic $input variable
[1] It is for this reason that the outer '...' quoting does not protect the unescaped " inside it: During the initial parsing of the command line, ' characters have no syntactic meaning.

Python script through SSIS

This is how I am executing my python from Execute process in SSIS:
I have the same command in .bat file and I can execute .bat from SSIS execute task but if I put the whole command like above it doesn't work. Any help is appreciated.
Error I get is
The process exit code was "2" while the expected was "0".I have attached the screenshot of my SSIS executeprocess taskenter image description here
C:/Users/datadude/AppData/Local/Continuum/miniconda3/envs/ra_platform-201909/python.exe e:/Source/Scripts/Python/rapc/kozuchi/core/qc/solactive_returns_qc.py --datasource solactive
As comment from Nick.McDemaid says - to get proper help you need to provide better diagnostics. Try running it in Debug mode in SSIS as Execute container first and show the errors output? Here is a shot at an answer though, maybe it will help others.
I think the problem is in the way you use quotes in the Arguments field. The Arguments field is treated somewhat surprisingly by SSIS. In my tests it was always quoted (extra surrounding quotes added by SSIS) when passed as an argument to the command (Executable) of the execute process task.
I had similar problem when I was trying to evaluate a variable to be passed as an extra argument to a python script (i.e. part of the arguments field). The whole Arguments string was quoted and variable not evaluated.
The solution (to my problem) was to use Expressions (third option on the left in the dialog), and select Arguments as an expression. Then the Arguments expression was fully flexible. In your case I think you do not need the quotes, or should try building the Arguments as an expression.

SSIS Execute process call to dtexec.exe failing

I am trying to set up an SSIS package that calls other packages via a execute process task. All was working fine until I decided to try to execute the packages with a configuration file. The original expression was:
"/REP E /f " + #[User::screenName] + ".dtsx "
I changed it to
"/REP E /conf .\\<myconfigfile>.dtsConfig /f " + #[User::screenName] + ".dtsx"
which got me The process exit code was "4" while the expected was "0".
and
"/REP E /conf d:\\<dir1>\\<dir2>\\packages\\<myconfigfile>.dtsConfig /f " + #[User::screenName] + ".dtsx"
which got me The process exit code was "6" while the expected was "0".
If I take the command and run it from a command line, like so:
dtexec.exe /REP E /conf .\<myconfigfile>.dtsConfig /f <myssispackage>.dtsx
or
dtexec.exe /REP E /conf "w:\<dir1>\<dir2>\<myconfigfile>.dtsConfig" /f <mySSISpackage>.dtsx
it works fine.
Is there any way at all I can get a better error message? I think there's something about the expression that's causing problems.
Make sure to target the correct dtexec executable. Maybe your PATH is different when executed from the command line to the one used in Execute Process task.
A good suggestion from http://www.sqlservercentral.com/articles/Integration+Services+(SSIS)/126293/ is to search the hard drive for all appearances of it. There are very detailed instructions in that article for more than that.
Edit: Ouch, maybe exit code has something to tell us?
https://learn.microsoft.com/en-us/sql/integration-services/packages/dtexec-utility#exit
4: The utility was unable to locate the requested package. The package could not be found.
6: The utility encountered an internal error of syntactic or semantic errors in the command line.
Errors of type 6 could be related to the escape characters.
What happens if you try to add some extra-escaped double quotes?
"/REP E /conf \"d:\\<dir1>\\<dir2>\\packages\\<myconfigfile>.dtsConfig\" /f " + #[User::screenName] + ".dtsx"

ns: 217: invalid command name "217" while executing "217"

I am simulating Wireless Sensor Network using NS2.35 and I get an error saying
ns: 217: invalid command name "217"
while executing
"217"
I have no where used such command throughput my tcl file. Can any one help why I get this error?
You've probably used a variable containing a numeric value as a command name, perhaps by putting it at the start of a line or by placing [brackets] around it (because brackets do command substitution). The brackets can be even embedded in a string:
This example demonstrates what I mean:
set xyz 217
puts "This is [$xyz] in brackets"
If you want to print some literal brackets out around a variable, you have to add some backslashes:
set xyz 217
puts "This is \[$xyz\] in brackets"
The problem could also be if you've got a command that returns 217 and you've put brackets around it at the start of a line (or in other places where a command is expected):
proc xyz {} {
return 217
}
[xyz]
You've not shown us your code so which exact possibility it is… we can't tell. But I bet it'll be one of these problems. Tcl cares about its syntax characters, and is very exacting about making sure they do what they say they do.
invalid command name "217" :
"217" is an internal command in your 'ns' executable.
Please tell which changes you made to ns-2.35/, if any. (WSN ?)
And please upload your "wsn.tcl" file to e.g. 'Google Docs'.
ns2

run from Shell R function with json string parameter

I have function, that works with json string.
When I try in R:
my_function('{"menu":{"id":"file","value":"File","popup":{"menuitem":[{"value":"New","onclick":"CreateNewDoc()"},{"value":"Open","onclick":"OpenDoc()"},{"value":"Close","onclick":"CloseDoc()"}]}}}')
it works well.
But when I try in Shell command:
R -e "source('./my_function.R'); my_function('{"menu":{"id":"file","value":"File","popup":{"menuitem":[{"value":"New","onclick":"CreateNewDoc()"},{"value":"Open","onclick":"OpenDoc()"},{"value":"Close","onclick":"CloseDoc()"}]}}}')"
It fails with error:
unexpected character 'm'
.
Seems, that problem is with quotes in json string. How can I solve it?
P.S. I need to call my_function directly from Shell.
Thank you!
Write it main script like main.r,
source('./my_function.R')
my_function('{"menu":{"id":"file","value":"File","popup":{"menuitem":[{"value":"New","onclick":"CreateNewDoc()"},{"value":"Open","onclick":"OpenDoc()"},{"value":"Close","onclick":"CloseDoc()"}]}}}')"
Execute it from command terminal like,
Rscript main.r
please make sure you have R path configured.
You can't mix the quotes as you are doing. The shell is reading from your opening double quotes until the first double quotes it finds ( which is in your JSON string). It then sees an m (in menu) which it can't handle and gives the error message.