Passing workflow variables on a batch script

Hello.

I'm having some problems when I try to run a knime workflow passing a workflow variable.

In this case my variable is a Database URL ( an Access Database - .mdb).

I'm getting the following error:

 

Couldn't parse -workflow.variable argument: -workflow.variable=DB_URL,jdbc:odbc:
DRIVER={Microsoft: Invalid argument list

My batch file have the following configuration:

C:/Users/dri/Downloads/knime_2.7.0/knime.exe -nosplash -noexit -consoleLog -reset -nosave -workflowDir="C:/Users/dri/Documents/AHO/AHO KPI's/AHO KPI's/POLIO_0001" -credential=STG_DW;STG_AHO;RX0bbha8KsB4 -workflow.variable=DB_URL,jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ="C:\\Users\\dri\\Desktop\\CSV - AHO\\Access Databases\\PolioNationalLab_IPAFR2011_06wk4.mdb",String  -preferences="C:/Users/dri/Downloads/knime_2.7.0/preferences.epf" -application org.knime.product.KNIME_BATCH_APPLICATION

 

Anybody can help me with this problem?

When running in KNIME Client, even with the workflow variable, is working quite good !

Thanks in advance.

Joana Dias

Looks like the parameter for the workflow variable is not escaped and/or quoted correctly and the shell splits it up. If the value contains spaces it must be enclosed in quotes. If you have quotes inside the value you must escape them, usually by using a backslash.

Hi thor and thanks for your response.

I already tested with quotes in the paths that I passed in my variable and I'm still getting the same error.

Now my command is like that:

C:/Users/dri/Downloads/knime_2.7.0/knime.exe -nosplash -noexit -consoleLog -reset -nosave -workflowDir="C:/Users/dri/Documents/AHO/AHO KPI's/AHO KPI's/POLIO_0001" -credential=STG_DW;STG_AHO;RX0bbha8KsB4 -workflow.variable=DB_URL,jdbc:odbc:DRIVER="{Microsoft Access Driver (*.mdb, *.accdb)}";DBQ="C:/Users/dri/Desktop/CSV - AHO/Access Databases/PolioNationalLab_IPAFR2011_06wk4.mdb",String -preferences="C:/Users/dri/Downloads/knime_2.7.0/preferences.epf" -application org.knime.product.KNIME_BATCH_APPLICATION

 

and I tried to put the quotes like that too:

 

C:/Users/dri/Downloads/knime_2.7.0/knime.exe -nosplash -noexit -consoleLog -reset -nosave -workflowDir="C:/Users/dri/Documents/AHO/AHO KPI's/AHO KPI's/POLIO_0001" -credential=STG_DW;STG_AHO;RX0bbha8KsB4 -workflow.variable=DB_URL,"jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:/Users/dri/Desktop/CSV - AHO/Access Databases/PolioNationalLab_IPAFR2011_06wk4.mdb",String -preferences="C:/Users/dri/Downloads/knime_2.7.0/preferences.epf" -application org.knime.product.KNIME_BATCH_APPLICATION

 

Any idea?

 

Thanks

Hi Joana, have you resolved this issue? The command line looks okay for me, but there might be any issue with spaces and quotes? Can you try to execute a workflow without credentials and workflow variables, but with preferences. Cheers, Thomas

Hi Thomas.

I tested the same workflow but without worflow variables (but still with credentials) and works fine.

So it seems the problem is really in the workflow variables command.. I already try to change the quotes of it but the problem persists.

No more ideas..

Thanks

Joana 

Do you have any example with a mdb database workflow variable?

I'm running out of ideas to change the command..even with quotes in every path that have blank spaces is not working.

I put my database in a new directory (without spaces in the path) and it's still not executing and shows the same error.

the command:

C:/Users/dri/Downloads/knime_2.7.0/knime.exe -nosplash -noexit -consoleLog -reset -nosave -workflowDir="C:/Users/dri/Documents/AHO/AHO KPI's/AHO KPI's/POLIO_0001" -credential=STG_DW;STG_AHO;RX0bbha8KsB4 -workflow.variable=DB_URL,"jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:/Users/dri/Desktop/PolioNationalLab_IPAFR2011_06wk4.mdb",String -preferences="C:/Users/dri/Downloads/knime_2.7.0/preferences.epf" -application org.knime.product.KNIME_BATCH_APPLICATION

Since the comma is a separator for the three parts of the workflow variable argument (name, value, type), you must quote any values that contain commas. I.e. the arguments should look as follows:

-workflow.variable=DB_URL,"\"jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:/Users/dri/Desktop/PolioNationalLab_IPAFR2011_06wk4.mdb\"",String
 

The outer quote are to prevent the shell from breaking the argument apart at the spaces and the inner quotes (which must be escaped) are to prevent splitting the variable value at the comma.

1 Like

Hello thor.

It's working fine now =]

Thank you very much for the help !

Regards,

Joana Dias

Having fought this battle myself, with a complex workflow variable set by the command-line, I will offer this bit of advice for the next person. 

Write a very small workflow that simply echos the variable into a file.  I chose to write it as a comment into a csv file.  That's the only way I was able to debug all the quoting and escaping.

Cheers,

Bill

Hi All,

I have many workflows variables defined in my workflow and all of them should be overriden in batch mode. Can some one help me in passing a file to command line execution. so the command line should look like below.

C:/Development/DevTools/knime_2.7.4/knime.exe -nosplash -noexit -consoleLog -reset -nosave -workflowDir="C:/Development/IRIP-Development/Version1/TEST/test2"
-workflow.variable.filePath=C:/Development/DevTools/Parameterfile.txt -application org.knime.product.KNIME_BATCH_APPLICATION

so the parameter file should have all the workflows variables defined in it as below

variable1,name, string

variable 2,number,string

variable3,joindate,date

 

Cheers

Meeravali