CFExecute do not execute command
<cfset LOCAL.cmd = expandPath('..\library\gm.exe') />
<cfset LOCAL.args = "convert image1.jpg image2.jpg" />
<cfexecute variable="gm" errorVariable="error"
name="#LOCAL.cmd#"
timeout="10"
arguments="#local.args#" />
<cfdump var="#gm#" />
This code always results in an empty line in gm. Regardless of how I execute gm with or without parameters. Other examples work fine how cmd.exe or netstat.exe works like in CFDocs example. I don't get any errors or warnings in errorVariable, it just doesn't do anything.
I changed the code, this version also doesn't work:
<cfset LOCAL.cmd = expandPath('..\library\gm.exe') />
<cfset LOCAL.args = "convert ""#variables.uploadDirectory##LOCAL.file.source#"" ""#variables.uploadDirectory#optimal-#LOCAL.file.source#""" />
<cfexecute errorVariable="error"
name="c:\windows\system32\cmd.exe"
timeout="10"
outputFile="#expandPath('.\gm.log')#"
arguments="/C #local.cmd# #LOCAL.args#" />
a source to share
Permission problems are the most common cause. However, if you are using CF8, you can also try redirecting the error stream and add an explicit completion flag . Just to see if you get any result or see different behavior. Earlier versions did not display the error stream, which caused some processes to hang. It was fixed in one of the updated CF8 programs.
Update: I just noticed that your image paths are relative. The program may have difficulty finding them. Try using absolute paths for images.
Update: I tested it with CF9. It works when using absolute image paths. Although the "gm" variable is understandably empty, since the output is directed to an image file.
<cfexecute variable="gm"
errorVariable="errorOut"
name="C:\GraphicsMagick-1.3.12-Q16\gm.exe"
timeout="10"
arguments="convert c:\art.gif c:\artCopyFromCF9.gif" />
<cfdump var="#variables#">
a source to share
Without looking at the code or server setup, I would suggest that you need to check the permissions for the CF user account.
If CF is running under the default user, you may need to create a user with access to what you are trying to do. Then change the service (s) to run under that user. Alternatively, you can assign more liberal permissions to the resource you are trying to access.
a source to share
I also ran into this with cfexecute and GraphicsMagick. I believe the deal is that the GM runs asynchronously and returns before it completes. Running some tests with outputFile / errorFile instead of their variable equivalents, followed by cffile reading fileInfo in the output file (which is empty in the test script, but as noted has content when opened), I can see that the modified time is the output file with contents actually after the last modified timestamp provided by FileInfo.
I think if you output to a session variable or something similar that might be matched by another template, you can observe the execution results by populating the session variable, assuming the other template is executed after the variable is actually set.
a source to share