开发者

CFExecute not performing 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 string in gm. No matter how I execute gm with or without parameters. Other examples work fine like running cmd.exe or netstat.exe as is in the CFDocs example. I get no errors thrown or warnings in errorVariable, it simply does nothing.

I modified the code, this version does not work either:

<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#" />


Permissions problems are the most common cause. However, if you are running CF8, you might also try redirecting the error stream and adding an explicit terminate flag. Just to see if you get any output or see different behavior. Early versions did not capture the error stream, which caused some processes to hang. It was fixed in one of the CF8 updaters.

Update: I just noticed your image paths are relative. Perhaps the program is having difficulty locating them. Try using absolute paths for the images.

Update: I tested it with CF9. It does work when using absolute image paths. Though 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#">  


Without seeing code or your server setup, I would guess you need to check permissions for the user account CF runs under.

If CF is running under the default user, you may need to create a user with access to whatever it is you are trying to do. Then change the service(s) to run under this user. Alternately, you could assign more liberal permissions to the resource you're trying to access.


I have also encountered this with cfexecute and GraphicsMagick. I think the deal is that GM is operating asynchronously and returns before it completes. Running some tests with outputFile/errorFile instead of their variable equivalents, followed by cffile reading the fileInfo on the output file (which is empty per the test script but observed to have contents when opened), I see that the modified time of the output file with contents is actually after the last modified timestamp yielded by FileInfo.

I think if you output to a session variable or something of the sort that could be picked up by another template you could observe the results of the execution having populated the session variable, provided the other template executes after the variable is actually set.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜