setting flow variables on command line?

I want to run a KNIME workflow from the command line (headless) and set a flow variable. Is there a way to do this? I found the FAQ entry on how to run a KNIME workflow from the command line in headless mode. It shows how to set a specific property on a specific node (cool!). But in my case, I want to enable a workflow variable, use the variable in a node, and then set the variable when running from the command line.

Any way to do this?

Thanks in advance!

1 Like


I would use the quickform nodes. You can add them to your workflow and modify their values from the command line.



There is also another command line flag that allows you to set a workflow variable (name of variable must be defined on the workflow):

 -workflow.variable=name,value,type => define or overwrite workflow variable
                  'name' with value 'value' (possibly enclosed by quotes). The
                  'type' must be one of "String", "int" or "double".

If you run the batch executor with no arguments you get a list of all options.




I appreciate the extensive capabilities of KNIME, but I am stuck on one point related to this thread.  I am interested in running KNIME from the command line, and need to be able to pass dates to a stored procedure executing on a T-SQL database.  My Database Reader node has the command exactly as shown below (no additional single- or double-quotes):


execute sql.dbo.Test_Knime  '1/1/2011', '5/1/2011', '5/1/2011', '6/1/2011'


I have created a Workflow Variable called SQLCommand, of type string, whose value is exactly


execute sql.dbo.Test_Knime  '1/1/2011', '5/1/2011', '5/1/2011', '6/1/2011'


(I have also created a simple test Workflow Variable called MyTest that is an integer with a default value of 123456.  I output that in a comment field in my CSV Writer node.

The command to execute this (in DOS) is:


knime -consoleLog -noexit -nosplash ^
      -reset -failonloaderror ^
      -application org.knime.product.KNIME_BATCH_APPLICATION ^
      -workflowDir="C:\Users\williamn\Documents\KNIME\Classifier" ^
      -workflow.variable="SQLCommand","execute sql.dbo.Test_Knime  '2/1/2011', '6/1/2011', '6/1/2011', '7/1/2011'",String ^


This dies with the error message:


Couldn't parse -workflow.variable argument: -workflow.variable=SQLCommand,execute sql.dbo.Test_Knime  '2/1/2011', '6/1/2011', '6/1/2011', '7/1/2011',String: Invalid argument list


I have tried various versions of quotes but I am just guessing.  Removing the first workflow.variable parameter set (and leaving MyTest) generates the expected, successful result.

Thanks in advance for any help.

Bill N

1 Like

Here is the solution for my problem (at least, a solution, and in DOS only):


-workflow.variable="SQLCommand","\"execute sql.dbo.Test_Knime  '2/1/2011', '6/1/2011', '6/1/2011', '7/1/2011'\"",String


The outer set of double-quotes is required to get the whole string to the command-line parser - otherwise it will stop on the first space (after "execute").  The inner set needs to be protected with backslashes, or the commas get eaten by the wrong parser.

Hope this helps someone.


Excellent - 8 years later and this is still valuable resolution. Thank you!

I’m reading this on 2021… so 10 years later… :wink:

1 Like