Problem with Execute Command

Post Reply
mclarke
Member
Posts: 54
Joined: Thu Feb 28, 2013 5:29 pm
Location: Syracuse, NY

Problem with Execute Command

Post by mclarke »

I'm trying to get Execute Command to run the *.exe of CSV Splitter and can't seem to find the right arguments. I always have problems with this applet and there is no good documentation for it. I've read the Help and it doesn't really go into specifics on *how* you can get the arguments to work, use of the variables (%1, etc..) and how to use Switch variables in it.

Here is what I have:
Flow-example.PNG
Flow-example.PNG (5.01 KiB) Viewed 10989 times
Capture.PNG
Capture.PNG (14.99 KiB) Viewed 10990 times
I would really like to be able to split a file that I put in the incoming folder and have the output of the program go into the outgoing folder, since I will need to work with them some more inside Switch. But, the above was an example of me just copying the command line arguments from the readme to try and get it to work without an error.

What am I doing wrong?
Padawan
Advanced member
Posts: 358
Joined: Mon Jun 12, 2017 8:48 pm
Location: Belgium
Contact:

Re: Problem with Execute Command

Post by Padawan »

I am assuming that if you run the following command in the Windows Cmd that you correctly get the output in c:/csvsplitter folder, correct. If not, then you will first have to make adjustments to it so it works.

C:/csvsplitter/csvsplitter.exe filename="c:/csvsplitter/newfile-benchmark.csv" outputfolder="c:/csvsplitter" rowcount=50000 firstrowheader=1 repeatheader=1

Once you are sure it works we can translate it to a setup of the Execute command tool. I believe it should be this:

Execution mode: Concurrent (this is assuming that your csvsplitter can handle being called multiple times simultaneously, but most applications can)
Command or path: C:/csvsplitter/csvsplitter.exe

arguments:
filename="%1" outputfolder="%3" rowcount=50000 firstrowheader=1 repeatheader=1

Output: Result in folder

Fail if exit code is "non zero"

Can you try this?
If it fails, please enable debug logging in the logging category of the general switch preferences and reproduce the issue again. Then check the messages, adjust the filter in the type column to show debug messages and copy paste all the debug messages of the execute command here. In those messages the output of the command will be displayed (the things you see in cmd as output when you run the command there).
mclarke
Member
Posts: 54
Joined: Thu Feb 28, 2013 5:29 pm
Location: Syracuse, NY

Re: Problem with Execute Command

Post by mclarke »

Yes, I tested the program at the command line and it worked as expected.

I changed the arguments as you listed and made sure that the execution mode was concurrent. Failed, but the logs show an interesting error. The program was trying to access the Switch folder in AppData and was denied. I tried changing the "out" folder in the flow to a non-managed folder, but that did not solve the problem. I think when the program is trying to make it's split files in the temp folder, it's being told by Windows Server 2019 that it does not have the rights. Any idea how to give it elevated credentials?

Also, for other people trying to figure out to use Execute Command, it looks like you use the argument variables (%1, %3) to insert Switch paths into the processing of the job. If you look at the debug log posted, Switch substituted it's own paths for the command line arguments that the program needed to run.

Code: Select all

2020-05-21T12:44:00.144Z	debug	Split csv file	newfile-benchmark.csv	Execute command		stderr: 
2020-05-21T12:44:00.141Z	debug	Split csv file	newfile-benchmark.csv	Execute command		"stdout: Cannot open file ""C:\USERS\ADMINISTRATOR\APPDATA\ROAMING\ENFOCUS\SWITCH"". Access is denied"
2020-05-21T12:44:00.138Z	debug	Split csv file	newfile-benchmark.csv	Execute command		outcode [-1]
2020-05-21T12:43:59.304Z	debug	Split csv file	newfile-benchmark.csv	Execute command		"executing [""C:/csvsplitter/CSVSplitter.exe""  filename=C:\Users\Administrator\AppData\Roaming\Enfocus\Switch Server\backing\Split csv file\automanaged\Folder 1\_0012D_newfile-benchmark.csv outputfolder=C:\Users\Administrator\AppData\Roaming\Enfocus\Switch Server\temp\6\ScriptElement\8\2\ExecuteComandTemp rowcount=50000 firstrowheader=1 repeatheader=1]"
2020-05-21T12:43:59.298Z	debug	Split csv file	newfile-benchmark.csv	Execute command		arguments [filename=C:\Users\Administrator\AppData\Roaming\Enfocus\Switch Server\backing\Split csv file\automanaged\Folder 1\_0012D_newfile-benchmark.csv outputfolder=C:\Users\Administrator\AppData\Roaming\Enfocus\Switch Server\temp\6\ScriptElement\8\2\ExecuteComandTemp rowcount=50000 firstrowheader=1 repeatheader=1]
2020-05-21T12:43:52.383Z	debug									"'Scan now' was triggered for the path 'C:/Users/Administrator/AppData/Roaming/Enfocus/Switch Server/backing/Split csv file/automanaged/Folder 1' (object id '2', flow id '6')"
2020-05-21T12:41:54.288Z	debug									Flow 'Split csv file' is being activated
mclarke
Member
Posts: 54
Joined: Thu Feb 28, 2013 5:29 pm
Location: Syracuse, NY

Re: Problem with Execute Command

Post by mclarke »

So, after some further testing, it looks like CSV Splitter does not like the really long path required to read from and send to files inside a flow. I tested the app at the command line and tried to get a result using files inside the flow's backing folders and received the same error in the Command window that showed up in the log.

That led to some playing around with various setting for the arguments and the output setting. What finally worked was the following:
The attachment Working-settings.PNG is no longer available
I had to set the incoming and outgoing folders to locations outside of the Switch internal paths, which finally yielded results from CSV Splitter. I just linked the "output" folder to a new Switch-managed folder as next in line to keep them moving in the flow. Had some odd file names, though. See next screenshots. Padawan, would you have any other ideas on how to get it to work without having to use external folders?
The attachment New-flow.PNG is no longer available
Working-settings.PNG
Working-settings.PNG (10 KiB) Viewed 10963 times
Padawan
Advanced member
Posts: 358
Joined: Mon Jun 12, 2017 8:48 pm
Location: Belgium
Contact:

Re: Problem with Execute Command

Post by Padawan »

So this is the error you encountered:

Code: Select all

"stdout: Cannot open file ""C:\USERS\ADMINISTRATOR\APPDATA\ROAMING\ENFOCUS\SWITCH"". Access is denied"
The "Access is denied" part is not the important part here. The message is saying that it cannot open a file on path "C:\USERS\ADMINISTRATOR\APPDATA\ROAMING\ENFOCUS\SWITCH". This pathl is an incomplete path to the input file. So the reason csvsplitter can't open the file is because it is looking in the wrong location.
I think that the "Access is denied" part of the message is becauce csvsplitter can't see the difference between a not existing path and an existing path without read permissions, but this is just guessing on my part.

When you supply arguments to command line tools, then the arguments are separated by spaces. The problem here is that the path behind %1 has a space in it. I assume in your uses chosen location you had a path without a space in it?

When you have an argument with a space in it, then you can tell the command line application that it is part of the argument by placing the complete argument within quotes.

This is also the reason why I placed quotes around %1 and %3 in my settings. Did you also try it with these quotes?

If it doesn't work using the quotes the way I suggested, then you can try to place them like this:

arguments:
"filename=%1" "outputfolder=%3" rowcount=50000 firstrowheader=1 repeatheader=1
mclarke
Member
Posts: 54
Joined: Thu Feb 28, 2013 5:29 pm
Location: Syracuse, NY

Re: Problem with Execute Command

Post by mclarke »

In the previous testing, I was using paths with no spaces. I learned a long time ago using folder names with spaces is just asking for trouble. So, instead of a space, I use a dash (-). Of course, the Switch installation has no such rule, so there were spaces in that path.

Originally, this morning, I missed that you had put the argument variables in quotes. That's what I get for reading small type so early in the AM. I did have to have the entire argument in the quotes ("filename=%1" "outputfolder=%3") for the command to work correctly and using the Switch backing folders.

Thank you for all your help. I really appreciate it. Also, I would like to point out for any Enfocus people that read this forum, it would be most helpful if some of this practical information made it's way into the user guide. Always assuming your audience has years of programming experience and only needs the barest minimum of explanations is what causes new users so many headaches.
Post Reply