Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Run command tool questions

jeffv
8 - Asteroid

Hi,

Need some help on the run tool command.  I have read several articles on community but while I think I understand them since I can't get it to work I must not really understand them.

 

As an example:
I create a file script.bat with following commands:

@Echo off
title my test batch script
echo Hello!!!
pause
exit 0

 

I create an empty workflow and pull run tool on canvas.

 

In the [Run external program command] field I enter:  <my file loc>\script.bat

 

I don't enter anything in [Command arguments [Optional]] or [Working directory [Optional]] fields. Nor check either [run minimized] nor [run silent] check boxes.

 

Again I have tried to read and follow community articles to use the tool without success.

 

Though it says [Write Source [Optional]] is optional, which I understands purpose is file input for script.bat I cannot get by without something entered.

 

Sidebar:   Name [Write Source [Optional]] seems incorrectly named if it is indeed input to [Run External Program Command].  Can someone explain why it is named that way?

 

Then [Read Results[Optional] makes me think it is optional but keeps giving me an error if I don't have something entered.  Again through reading I understand this to be the output of
[Run External Program]  Why is it named Read Results and not something like command output?

 

It's obvious I have misunderstanding [write source] and [read results] as I keep getting errors such as the file I gave for [read results] doesn't exist.

Presently for unknown reasons as a test I have a Text Input connect as incoming to Run Tool, though my understanding according to what I've read that this is optional one dummy row.

 

Also a browse tool as going out from right side of Run Command tool.  I get an error: Run Command (1) Error opening c:\temp\alteryx.log no fields found.

 

I'd appreciate any ideas to why the error and misunderstandings of the run command tool?

 

Thanks,
Jeff

2 REPLIES 2
patrick_digan
17 - Castor
17 - Castor

@jeffv I'll do my best to try and explain some of the good questions you brought up. I did attach a working example on my end (version 11.0) to hopefully get you started.

 


@jeffv wrote:

 

 

Sidebar:   Name [Write Source [Optional]] seems incorrectly named if it is indeed input to [Run External Program Command].  Can someone explain why it is named that way?

 


The run command tool requires that either the Write Source or Read Results be connected. So they're optional in the sense I didn't use the read results in my attached examples. The confusing part is that they can't both be optional at the same time. It won't let you just run a command if no write source is connected. Perhaps you can submit that as a product idea if it isn't already there.

 


@jeffv wrote:

 

Then [Read Results[Optional] makes me think it is optional but keeps giving me an error if I don't have something entered.  Again through reading I understand this to be the output of
[Run External Program]  Why is it named Read Results and not something like command output?

 

 


The naming convention can be confusing. I think they intended it to work like this: You would use the write source to write some data to a file. You then use the command feature to call your program which uses that data file as an input. Your program would somehow process that data file and create an output file. You would use the read results of the run command tool to read in that output file. 

 

In the attached example, Container 5 is running your static, already created bat file. As you figured out, I'm just connecting a dummy text input to the run command tool to get it to work. I chose to write it to the temp directory %TEMP% so that it just writes the data in a throw away spot that gets cleaned up. 

 

Container 6 is an example where you can actually write the bat file at runtime. Since my alteryx workflow is a yxwz file\app once Alteryx unzips the yxzp, I can use the text box to get user input. You'll notice that I renamed my textbox "Text":

Capture.PNG

 

Then in line 3 of my text input tool I've grabbed the user entered info like so:

echo %Question.Text%

So the user can now specify what is echoed out.

 

You can use the %Type.Name% syntax for any of the variables listed in the workflow tab. When you add a new interface tool, it will show up there.

Capture2.PNG

Note that I've entered the test value "this is my sample text" in the the value column. This now allows me to run this as a normal workflow (control + R or the green circle with white triangle) and try different test values to verify that it's working. It's literally replacing %Question.Text% with whatever value I enter in the value column. You can see the text come through in the cmd window:

Capture.PNG


Now that I know it's working, you can run it as an app (the magic wand icon):

Capture.PNG

Capture2.PNG

 

Let me know if you have any other questions!

jeffv
8 - Asteroid

Thanks for your reply and examples...  it may take me a bit of playing with it to fully feel comfortable with it.  Just seems a bit awkwardly named I guess.

 

From your example I can see/understand container 5 example.  Seems odd one has to put a dummy data for [Write Source] data coming in but can accept that's the way it works.

 

Container 6 takes it further and I'll need study this a bit further.  Cool you can create a batch file to be run.  Interesting the steps to create the batch file.  The part I'm trying to put my arms around yet is the get the input from the app and passing it to the field [question.text] for use in batch file.  I see by your download but I guess haven't done apps yet.  I'll play with it and try to figure it out.

 

Thanks,

Jeff

Labels