This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
The Run Command tool is a great way to take your workflow to the next level of efficiency. It allows you to interact with the command line directly, just as you would if you were to access it manually and type in a command. Which is great because sometimes we have a lot of important things to do in the command line.
This post will discuss two features of the Run Command tool: the Read Results and Write Source configuration options. You'll note that they both say "optional", but the Run Command expects one or the other to be configured (or both) and will error if they are blank. These options both deal with files that are either used in the command (Write Source), or created by the command (Read Results).
Let's start with that second case - you have a command line command being carried out in the Run Command, and you want to spit out the results to your workflow. The Read Results option allows you to grab the output of your command and bring it into your Alteryx workflow.
If you stream anything out of the Run Command, you must configure the Read Results.You may wonder why you need a file to stream in the result from your command - Just remember this is all happening outside of Alteryx, so if you want to bring something back into Alteryx you need to treat it as a data source.
You can configure this like an Input Data tool, by clicking “Input…”.
The example here was taken right from our documentation on the tool, and shows how we can create a temporary file in the command, navigate to it in the Read Results, and have that pass into the workflow after the Run Command tool.
This option would allow you to take some information from your workflow and incorporate it as a source in your command, sort of like how Neo suits up in the Matrix.
Actually, it's exactly like that.
The example I included on this article uses a field in Alteryx with the entire command, and then writes that to a temporary .bat file. The Run Command then simply reads the batch file and executes the command. I also included a Read Results here so we can see the output in the workflow, but it isn’t necessary.
Just like before, if you stream anything into the Run Command, even if you don't use it in the command itself, you must also have the Write Source configured.
Sometimes you may get a weird error from the Run Command that is actually just being passed along from the command line. Most of the time these will tell you where they're from, and they will almost always just be pointing at something wrong in your Command Arguments.
These will usually have a error code associated with them as well - these are actually Windows error codes, so you may be able to find some more information by Googling around.
2. Input Schema:
Depending on the data you're bringing in, you may need to play with your Input Tool configuration to account for header rows, or wonky metadata. To get around these sort of things, try to treat your data as non-delimitted by configuring your Input as below:
We’ll just have to make sure that our delimiter is set to \0 and that we don’t have the First Row Contains Field Names option checked. The "\0" is just a shortcut to tell Alteryx to use no delimiter when parsing fields – so all the text will come in natively separated only into rows. The “long way” is brought up in the Resolve File Type window that will pop up if you use a file type that is not in the drop down menu of the Input Tool configuration.
Thanks for reading!
Example workflow compiled in Alteryx Designer 10.6.