A user just wrote to me to ask about using <CFEXECUTE>. He was trying to execute a command-line utility (based on an example I posted back in CF 5 days) and the code kept throwing Java errors. His specific problem turned out to be one of pathing, pre CFMX you may not have needed to provide fully qualified paths (for example, the path to cmd.exe) but now you do.
The following is a simple test, it invokes netstat and displays the results:
<cfexecute name="c:\windows\system32\netstat.exe"
variable="data"
timeout="10" /> <cfdump var="#data#">
Executing a shell command (like DIR and SET) is a little trickier. You can't execute set directly, you'll need to execute the command interpreter (cmd on Windows) and have it execute set. And you MUST pass /c as an argument - this tells the command interpreter to run and terminate upon completion, without /c it will be waiting for an explicit exit command and will never return.
Here is an example using set:
<cfexecute name="c:\windows\system32\cmd.exe"
arguments="/c set"
variable="data"
timeout="10" /> <cfdump var="#data#">
Note: Obviously these example are Windows specific.
I'm trying to use cfexecute to run a command line java class and I'm getting an IO error....do I have to allow for this tag to be run, ie cf7 disable or enable this by default. Do I have to run this under a an account that's not local?
Thanks
-Luis
I try to use CFEXECUTE for lunch a format changer for movie (ffmpeg.exe)
I Make a .bat for run this transforme en flv.
When i execute the bat normaly (run whis argument) no probleme all is correct. but when i lunch it whis CFEXECUTE, the ffmpeg do not wand 'stop' the process, impossible to read the file (file used by a other application).
I try to use ffmpeg directely in CFEXECUTE whis argument, but shame effect.
I try different possibility, allway shame effect .. :(
and allway used directely thats work.
this is realy strange no ?
Thanks
I've looked at your comments above and confirmed the netstat information was returned to the screen.
I have a batch file d:\test.bat which I would like to execute to run on the server.
My command is as follows
<cfexecute name="d:\test.bat"
timeout="10">
</cfexecute>
This will echo the contents of the file test.bat to the screen rather than execute the file.
Am I missing something simple
Did you by any chance answer Alain's question (Posted By Alain | 12/9/06 3:32 AM) before? I think I do have the same problem.
Actually I do want to download a file within CF from a MVS mainframe secure (SSL) FTP site and I do that by using command line options of a third party FTP client.
Now, I did write a batch file (batchFile.bat) and when I double click it, it works fine... downloads the file, creates the two log files and etc. However, when I do execute that same batchFile using cfexecute it creates the two log files but hangs on. does not download the file nor writes anything into the log files.
I wrote a smilar batch file just to test, which creates a directory and a file within, and then deletes those altogether, and it works... it does not hang up...
Is there a trick to run a third party command line within cfexecute? I am lost...
your input is very much appreciated....
Thanks,
It may be a permissions issue, depending on what your batch file is doing. You may want to try having CF execute under a user account (instead of system service account) to see if it works then.
--- Ben
I am trying to run an executable which takes a pdf file as input and returns a tiff file. I am trying to use cfexecute but I am unable to execute that.
i wrote the executable in a bat file
Here is the bat file
path\ConvertPDFToImage.exe /S path\Input\Coffee.pdf /T path\Input\Coffee.tiff /C3
ur input is appreciated,
Thanks
Sandhya
It works for a single command under unix.
But for example, unix commands can be strung together, and cfexecute can't handle the pipe and subsequent command.
i.e.: more ./cfseerver.log | grep 'Coldfusion Starting'
Is there a work around???
I was running into the same problem with the batch file showing on the screen as well. You need to add either the variable or outputfile attribute (either are optional) in the command. According to the Adobe docs (as outlined here - http://livedocs.adobe.com/coldfusion/6.1/htmldocs/...): "If no outputfile or variable attribute is specified, output is displayed on page from which it was called."
So something like this would work for you:
<cfexecute name="d:\test.bat"
timeout="10"
variable="data">
</cfexecute>
I added the variable="data" to my cfexecute command and the contents of the batch file went away.