Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

Run command error code 1 nothing works

TH
8 - Asteroid

I've gone through every official explanation, community forum post, and stackoverflow thread that I can find, and so far nothing has worked.

 

The basic idea is that with a specific input format the macro will build and run a windows batch command to do some basic file movement, copying, renaming, that sort of thing. It's intended for someone to stick it into another workflow so that when they are trying to use files on their computer then they can do things to those without having to know batch command syntax or do the things manually.

 

You'll find attached the workflow of the macro. It's configured to test the "Copy" command with a source location and filename, a destination location and file name, and a flag to prepend the modification date to the file name during the copy process. It uses a python script to take the input, build the command, and spit it out again. You can ignore the rest of the code there because the only thing that is pertinent for the test is the section for the "copy" command.

 

The trouble is that it only sort of works right. If I output to a .csv file, copy the command, and then run it in a command window (with appropriate adjustments for the "%" signs) then it works fine. You can check this by disabling the "Run Command" container (37) and enabling the .csv output container (35). Then just run the macro by itself, open up the .csv file that it creates, copy the command, put in a command window, and run (after you've adjusted the "%" signs so that you can run in that window instead of through the .bat file). Just make sure you have the appropriately name text file in your C: drive location.

 

The trouble arises when I disable the .csv container (35) and enable the run command container (37). What I expect that to do is to write the command to a .bat file in the temp directory and the run that .bat file. What I get instead is an error message that, apart from the exact name of the temp directory, is exactly the same as the following.

 

Run Command (38) The external program "C:\Alteryx-Temp\Engine_8308_d9ee159f71db604cb828bc0301c82bd6_\RunCommand.bat" returned an error code: 1

 

As I said above, I've gone through every official explanation, community forum post, and stackoverflow thread that I can find, and so far nothing has worked.

Can you get this batch file to run? What did you do to make that happen?

 

 

14 REPLIES 14
OTrieger
12 - Quasar

@TH 
Can you paste here the path you get in the bat file?

OTrieger
12 - Quasar

"Then just run the macro by itself, open up the .csv file that it creates, copy the command, put in a command window, and run (after you've adjusted the "%" signs so that you can run in that window instead of through the .bat file). Just make sure you have the appropriately name text file in your C: drive location."

Does the path in the bat file contains %?

If yes, then the command will fail, it command in the bat file must be clean.

TH
8 - Asteroid

OTrieger,

Not explicitly. The path is %temp%\RunCommand.bat because that's how you run a command without actually having it already written on your computer before the program is run. One of the main points of this macro is that I need to dynamically create the command during the workflow run. The batch command does not and cannot exist beforehand.

 

As far as the percent characters, there's a difference between typing things into the command line and running them from a batch file. You can type some commands into the command line, yet when you run them you have to add extra percent signs. This is how the command line interface and batch files work. It's what windows requires.

 

That's what I've read everywhere that I've gone to investigate this problem. Please show me anything you can find that doesn't say you have to add percent characters when you're running a .bat file rather than just typing into the command line.

apathetichell
19 - Altair

@TH --- in testing write the .bat file to a non temp location. retrieve your .bat file. run your .bat file in command prompt -> see what error you get. troubleshoot. fix error. go back to temp location.

OTrieger
12 - Quasar

@TH 

As I wrote, check your bat file, what Alteryx write in it, your error comes form the command that Alteryx write to the bat file. When you will know what there is in the bat file you will know what to fix.

TH
8 - Asteroid

@OTrieger 

 

I do not think you are correct.

I am pretty sure that that is not where the error is coming from.

The research I've done suggests that double percent signs are the right way to build .bat files.

escaping - Ignore percent sign in batch file - Stack Overflow

What is the difference between % and %% in a cmd file? - Stack Overflow

command line - What does the percent sign (% and %%) in a batch file argument mean? - Super User

Percent symbols - % - Windows CMD - SS64.com

 

 

 

TH
8 - Asteroid

@apathetichell 

 

That would defeat the purpose of the macro. Part of the point is that a user can use the macro wherever they want to.

And there is no guarantee that that person will have access to the same file and network locations that I do. That's why I was using the %temp% location in the first place.

 

 

 

apathetichell
19 - Altair

@TH  --- let me rephrase that.

yes --- -of course.

once you have it working.

you are in development. what your are developing is not working. you must test it. you must troubleshoot your testing. what I am recommending is fix your error THEN institute the change you need for deployment.  

 

Or just ignore me and @OTrieger  and the next bunch of people who show up and try to explain to you that you can spend hours trying to fix what might be the problem or 10 minutes identifying what is the problem.

TH
8 - Asteroid

@apathetichell 

 

I may be a little touchy about solutions here. That's because I've tried these things. And they haven't helped.

Changing to single percent signs doesn't fix the error 1.

Changing the location of the batch file to a dedicated specific location doesn't change that I still get error 1 when I try to run the "Run Command" tool.

 

I appreciate that you both are trying to help. I have just already done a lot of investigating, and I have tried a lot of things already.

Labels