Free Trial

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
apathetichell
19 - Altair

@TH -hey - sorry - clarification I get that you see in this error in run command --- what about in command prompt? Ie outside of Alteryx. quite often the error 1 points to an issue with the .bat file which Alteryx is just conveying vs an issue with Alteryx.

SPetrie
13 - Pulsar

There is a select statement right before the run tool that is limiting the character to 64 which is truncating your command, so its not even writing a complete command.

Also, when you do remove that limitation, the batch file it is creating using the TestFile1 looks like this

 

for %%a in ("C:\TestFile1.txt") do set mod_date=%%~ta && copy "C:\TestFile1.txt" "C:\%mod_date:~6,4%%mod_date:~0,2%%mod_date:~3,2% TestFile2.txt" && exit /b

 

Your date its attempting to append to the file name is not parsing correctly. You will need to fix that part first.

TH
8 - Asteroid

@apathetichell 

The command runs just fine in command prompt.

During my investigations the only information I could find about error 1 was that it *could* mean that the file wasn't found.

I've talked to other people about this too, and it appears that the issue may be a combination of the way I've structured my command and the way windows interprets one-line batch commands.

 

The batch command I created was using the source file to set the modified date (into a variable) and then immediately (using ' && ' between commands) parsing that modified date into the new file name. Windows batch was trying to run those in quick succession. I believe that the issue was that windows didn't finish the first part (saving the modification date) before it tried to run the second part (copying the file with the new file name).

 

So the way that I am making the macro work is to change my code to use only '&' (no spaces) to combine the individual commands and then use a text-to-columns tool set to "split to rows" using "&" as a delimiter in order to turn a long string of commands into several short commands. I can hand that to the "Run Command" tool and it will do what I want.

SPetrie
13 - Pulsar

I wasnt able to get the batch to run the way it was originally written. I altered to to be this instead

 

for %%a in ("C:\TestFile1.txt") do (for /f "tokens=1,2,3 delims=/ " %%A in ("%%~ta") do (copy "C:\TestFile1.txt" "C:\%%C%%A%%BTestFile2.txt"))&&pause

 

This did run for me and inserted the date values in the new file name.. I replaced the exit /b with pause so I could see the results after run. If it runs for you as well, see if adjusting your creator to make this cmd instead helps. Also, make sure to increase the size in the select tool before the run command so its not being truncated.

 

 

apathetichell
19 - Altair

got to say - this might be easier using internal Alteryx tools and blob input/output.

Labels
Top Solution Authors