Run Command Tool
The Run Command tool allows you to run external command programs within Designer. This tool can be used as an input, output, or an intermediary tool.
Using the Run Command tool is similar to running applications directly from the Windows command line, but with the convenience of remaining within the Alteryx GUI. For example, you can use the tool:
- when Designer does not have needed functionality.
- in conjunction with curl.exe to download data from web or FTP sites.
- to call third party applications.
- to wrap custom functionality written in other programming languages.
If the program you are using does not set error flags, you should wrap it in a batch file to make sure the output file is deleted before it is run.
Configure the tool
When you run the workflow, the Run Command tool configuration is executed in sequence: Write Source, Run External Program, and then Read Results.
- Optionally specify a Write Source [Optional] output. The write source is data that comes into the tool as a file, SQL server connection, or any supported output type. Only specify a write source if you are using the Run Command tool as an output or intermediary tool.
- In the Run External Program section:
- Specify the external program Command: to run. For example, this could be a program that acts on a write source and generates read results.
- Type the Command Arguments [Optional]:, if any. Most commands are used together with one or more arguments. Whether arguments are required or optional varies by command.
- Optionally specify a Working Directory [Optional]:. If you leave this field blank, the default is the directory where the workflow is saved.
- Select Run Minimized to minimize the Run Command window to the task bar when Alteryx executes the external command.
- Select Run Silent to not display the Run Command window when Alteryx executes the external command.
If the external program is a UNIX-style command line app that takes input from stdin and writes to stdout, you can use the << and >> operators to pipe the information to and from files. For more information, see the Microsoft documentation.
The following example details an example use case and the resulting configuration.
- The tool is configured as an input file in the Alteryx workflow. Therefore, Write Source is left blank.
- The Command is curl.exe, which is a free and open source program that allows you to download files from a web page. For more information, see the curl documentation.
- Command Arguments includes the complete path of the file to be downloaded, as well as an output command and the file to output (in this case, -o "%temp%\temp.csv", which means to output (-o) the content from the web page as a file called temp.csv.)
- Working Directory is left blank to default to the directory where the workflow is saved.
- Read Results refers to the temp.csv file to return from the downloaded content and its relative path (%temp% references the temporary directory). The curl program has already downloaded the content and is handling the data as this .csv file. Alteryx is reading the .csv file as if it came from an Input Data Tool. The file can now be processed downstream.