Copy link to clipboard
Copied
My server is running the following:
I'm running some command line software to generate audio for a custom captcha form. I can't get this bat file to run with cfexecute. I can run the bat fine if I run it manually and it generates the .wav file but it will NOT run with cfexecute. I had tried running the exe with cfexecute while passing the arguments and all that outputed to the page was "[empty string]". I have read pretty much every forum post I can find searching through google and can't find the solution to my problem. Please someone help me out I'm wracking my brain over this.
Variables passed:
<cfparam name="FileName" default="">
<cfparam name="Cap" default="">
<cfset newString = "">
<cfloop index="intChar" from="1" to="#Len( Cap )#" step="1">
<cfset strChar = Mid( Cap, intChar, 1 ) />
<cfset newString = newString & "#strChar#.....">
</cfloop>
<cfoutput>
<cfsavecontent variable="cmd_content">C:\TSC.exe /s "#newString#" C:\Inetpub\wwwroot\captcha\#FileName# Mary (for Telephone)</cfsavecontent>
</cfoutput>
<cfset cmd_filename = "#ListFirst(FileName, ".")#.cmd">
<cffile action="write" file="C:\Inetpub\wwwroot\captcha\#cmd_filename#" output="#cmd_content#">
<cfexecute name="C:\Inetpub\wwwroot\captcha\#cmd_filename#" outputFile="C:\testoutput.txt" timeout = "90"></cfexecute>
This is the content of testoutput.txt when the script is ran:
C:\ColdFusion9\runtime\bin>C:\TSC.exe /s "N.....F.....A.....C.....Z.....M.....U.....2....." C:\Inetpub\wwwroot\captcha\NFACZMU2-050031.wav Mary (for Telephone)
What am I doing wrong?
Copy link to clipboard
Copied
I suggest starting slowly and working your way up. Specifically, forget those variables for a minute. Hard code the name of your batch file and try to run it with cfexecute. Also, you mention passing the arguments, but see nothing in your code to indicate such.
Copy link to clipboard
Copied
When I've done this before in the past, I've had better luck by running the batch file indirectly, as an argument to the command processor:
c:\path\to\cmd.exe /c c:\path\to\myfile.cmd ...
Dave Watts, CTO, Fig Leaf Software
Copy link to clipboard
Copied
I still can't get it to work that way. I changed my cfexecute to:
<cfexecute name="C:\windows\system32\cmd.exe" arguments="/c C:\Inetpub\wwwroot\captcha\#cmd_filename#" outputFile="C:\testoutput.txt" timeout = "90"></cfexecute>
And I changed my bat file to have:
<cfsavecontent variable="cmd_content">
cd\
TSC.exe /s "#newString#" C:\Inetpub\wwwroot\captcha\#FileName# Mary (for Telephone)
</cfsavecontent>
The output file is showing:
C:\ColdFusion9\runtime\bin>cd\
C:\>TSC.exe /s "3.....P.....4.....Z.....8.....U.....7.....X....." C:\Inetpub\wwwroot\captcha\3P4Z8U7X-105724.wav Mary (for Telephone)
I still can't get it to run the exe. I have watched the process list while running this and the exe doesn't show up. I tried cfexecute on the exe directly before trying the bat method, with hard coded arguments, and it still didn't work. I am so lost right now this makes no sense to me.
Copy link to clipboard
Copied
Try this to get more info. Put acfabort in front of the cfexecute code. Run your script - let it create the bat file and then stop before trying to execute it. Then go into a DOS box on the same machine and execute the bat file manually, see what happens. What does it give yoy for any errors, etc.
Good luck
reed