tags:

views:

105

answers:

2
<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#" />
+1  A: 

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.

Ben Doom
It's running as the local system, so it should have permissions to this file. It is all local on my file system. I will try messing with permissions on the file, shouldn't it be throwing a security error if this was the problem?
Drew
Correction, coldfusion is running under my user account. So permissions are definitely not an issue.
Drew
+2  A: 

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#">  
Leigh
I am running CF9, so I have the update that includes errorFile. I tried running this and did not receive any additional information in the stdout.
Drew
@Drew - A couple things a) As Ben asked, what are you expecting to happen? b) Does it actually work when executed from the command line and c) just for grins, have you tried using cmd.exe as the program and specifying gm.exe in the arguments?
Leigh
I posted comments above, I have updated the code to use cmd.exe directory and pass my program via /C. Also, I changed this to echo before the full path, copied this into a command prompt and it ran perfectly.
Drew
Leigh
I'll try that, I am using http://www.graphicsmagick.org/. It includes a gm.exe binary for doing simple image transformations.
Drew
@Drew - Okay. I have a feeling the image paths may be the problem. It is possible the program is looking for them in a different directory. So using an absolute path may help it be able to find them. I am surprised you are not getting an error though.
Leigh