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

Need help with the Command tool

Hakimipous
10 - Fireball

Hello everyone

 

Last week I was asking how to put a password on a pdf output and it seems (thanks to @jrgo that the cpdf exe is the way to go).

 

I did try it on Windows via the Command pront and it works fine.

 

here is what the command looks like: 

 

"C:\Users\XXX\Desktop\New folder\cpdf.exe" -encrypt AES  "test"  "test" -i "C:\Users\XXX\Desktop\New folder\JohnSmithResume.pdf" -o "C:\Users\XXX\Desktop\New folder\out.pdf"

 

So basically it takes the file JohnSmithResume.pdf, create a duplicate called "out" with the password "test"

 

 

Now where I'm stuck is to make it run on Alteryx via the Command tool. I'm fairly new with this so there is still a lot to learn about, but after reading a bit I've created a workflow where I tried to based on other workflow I've seen, only it doesn't work as it should. My difficulty is that I'm using a formula tool prior to the command tool because I will need the argument to be dynamic. (have to create different password for different files)

 

I'm uploading here my workflow and file if anyone could give me some light on what I have to change. 

 

Thanks again! 

 

 

12 REPLIES 12
Claje
14 - Magnetar

If you update the "Run External Program" piece of the Run Command tool to run "passBat.bat" it should work.

The problem here is that you are writing out to a bat file and then asking alteryx to run cpdf.exe, instead of using the .bat file that was written for your command.

 

You may also need to change the "Write Source" settings in this tool so that the "Quote Output Fields" option is set to "Never", and the "First Row Contains Field Names" option is unchecked as these can cause issues.

Hakimipous
10 - Fireball

Oh wow awesome it works ! Your remarks definitely worth to be mentioned to someone new trying at this.

 

I had to rework how I construct my path on the Formula tool as well to be looking like this :

 

' "C:\Users\XXX\Desktop\New folder\cpdf.exe" ' + ' -encrypt AES "test"  "test" -i '+ ' "C:\Users\XXX\Desktop\New folder\JohnSmithResume.pdf" ' + ' -o ' + ' "C:\Users\XXX\Desktop\New folder\out.pdf" '

The difficulty here was where to put the ' and " 

 

Just a last question.

 

How can I read results from my command tool ? 

  I did update the the path to  : 

 

' "C:\Users\XXX\Desktop\New folder\cpdf.exe" ' + ' -encrypt AES "test"  "test" -i '+ ' "C:\Users\XXX\Desktop\New folder\JohnSmithResume.pdf" ' + ' -o ' + ' "C:\Users\XXX\Desktop\New folder\out.pdf" ' + ' > ' + ' "C:\Users\XXX\Desktop\New folder"' + '"\MoveCommand.txt "' 

 

after a created a blank .txt file called batCommand then selecting it in the Read results Input option of the Command tool but can't seems to write anything

Claje
14 - Magnetar

Based on the command you have written here, it looks like you need to read in MoveCommand.txt instead of batCommand.  let me know if that works!

Hakimipous
10 - Fireball

oh yeah sorry that's a bad copy/paste from me.

 

the command I have is : 

 

 "C:\Users\XXX\Desktop\New folder\cpdf.exe" ' + ' -encrypt AES "test"  "test" -i '+ ' "C:\Users\XXX\Desktop\New folder\JohnSmithResume.pdf" ' + ' -o ' + ' "C:\Users\XXX\Desktop\New folder\out.pdf" ' + ' > ' + ' "C:\Users\XXX\Desktop\New folder"' + ' "\batCommand.txt " ' 

 

and I get the error message : 

 

Error: Run Command (5): Error opening C:\Users\XXX\Desktop\New folder\batCommand.txt: no fields found.

Claje
14 - Magnetar

I ran a really simple test file with the following CMD:
ECHO "HELLO WORLD">C:\Users\XXX\Documents\Results.txt

 

I then used the run command tool and read results from Results.txt and found that it did include the results I expected.


I would recommend validating your settings for reading in the input file - make sure that the Input is set so that Output File Name as Field is set to "No", and double check your delimiters to be safe.

Claje
14 - Magnetar

Hi,

I just reviewed the code you had and i think the issue may be double quotes in the file.  Try this after the '>' in your code.

 

+'"C:\Users\XXX\Desktop\New folder' + '\batCommand.txt"' 

Hakimipous
10 - Fireball

@Claje 

Still not working. I assume something is wrong with my command tool set up.

 

the end of my command looks like this :

 ' > ' + '"C:\Users\XXX\Desktop\New folder' + '\batCommand.txt "'

 

and here is attached a sceenshot of my configuration
 

Claje
14 - Magnetar

Would you be able to copy the text from the created .bat file directly and send it over?  You can anonymize the folder path/username information beforehand - it will just help me to see it as produced rather than trying to interpret the formula


Thanks!

Hakimipous
10 - Fireball

@Claje 

 

looks like this : 

 

 

"C:\Users\XXX\Desktop\New folder\cpdf.exe" -encrypt AES "test" "test" -i "C:\Users\XXX\Desktop\New folder\JohnSmithResume.pdf" -o "C:\Users\XXX\Desktop\New folder\out.pdf" > "C:\Users\XXX\Desktop\New folder\batCommand.txt "

Labels