I need to run a exe file on app server using coldfusion schedule task. I wrote code inside cfm file with cfexecute command below.
But the executable doesn't run with/without timeout clause in cfexecute. Can anyone point out what I'm doing wrong.
<cfsetting enableCFOutputOnly="false" requestTimeout="9600" />
<!--- Call executable --->
<cftry>
**<cfexecute name= "C:\npp.exe" />**
<cfcatch type="Any">
<cfoutput>(Cal): Error - #cfcatch.message#</cfoutput>
<!--- TO DO:Log error --->
<cflog application="true" log="application" type="Error"
text=" Error - #cfcatch.message#" />
</cfcatch>
</cftry>
<cflog application="true" log="application" type="Information" text=" executable called" />
Related
I need to remove the Directory(folder) from FTP server using coldfusion. My server folders looks like below,
/jawa/notes/test.cfm
/jawa/notes/test1.cfm
/jawa/notes/test2.cfm
/jawa/notes/test3.cfm
/jawa/test1.cfm
/jawa/test2.cfm
/jawa/test3.cfm
My question is, how to remove the 'jawa' folder. Because all files and notes folder is under 'jawa' folder. So, If we delete the root folder ( jawa ) then the whole directory and files.
Are these possible guys?
Here's a function I wrote many years ago to accomplish this task. It uses <cfdirectory> with the recurse="yes" option. This creates a query object in which I loop through and first delete files only. Then I run a second loop in reverse which then deletes the folders. This method has worked well with no issues over many years.
<!---
Private function that will clear a specified directory of all files, folders,
subfolders and files contained in subfolders.
--->
<cffunction name="clearFolder" access="private" returntype="string" output="no">
<cfargument name="dirPath" type="string" required="yes">
<!---
Step 1: Loop through all the files in the specified directory/subdirectories
and delete the files only.
--->
<cfdirectory action="list" name="qDirListing" directory="#dirPath#" recurse="yes">
<cfloop query="qDirListing">
<cfif qDirListing.type eq "file">
<cftry>
<cffile action="delete" file="#qDirListing.directory#\#qDirListing.name#">
<cfcatch type="any">
<cfreturn "failure: Error deleting file #qDirListing.directory#\#qDirListing.name#">
</cfcatch>
</cftry>
</cfif>
</cfloop>
<!---
Step 2: Now that the files are cleared from all the directories, loop through all
the directories and delete them. Note that you need to loop backwards through
the result set since the subdirectories need to be deleted before the parent
directories can be deleted.
--->
<cfdirectory action="list" name="qDirListing" directory="#dirPath#" recurse="yes">
<cfloop from="#qDirListing.recordCount#" to="1" step="-1" index="i">
<cftry>
<cffile action="delete" file="#qDirListing['directory'][i]#\#qDirListing['name'][i]#">
<cfcatch type="any">
<cfreturn "failure: Error deleting file #qDirListing['directory'][i]#\#qDirListing['name'][i]#">
</cfcatch>
</cftry>
</cfloop>
<cfreturn "">
</cffunction>
I'm still using coldfusion 8 and the file operation I wrote works for one application but when I reuse the codes for another application I got an exception error.
I'm just simply need to copy, rename and move uploaded file from one directory to another.That's all I need. And this is for Oracle bcp from csv file.
All the permissions have been checked and allowed, all of the paths have been checked and correct. Both application reside at the same coldfusion server (unix based).
Here is what I'm trying to do:
I'm calling my comp:
<CFSET DestinationLoc = "/space/users/www/data/temp/Archives/#Trim(session.usergroup)#/">
<CFSET SourceLoc = "/space/users/www/data/temp/#Trim(session.usergroup)#">
<CFSET FileName = "#Trim(CFFILE.ServerFile)#">
<CFSET CopyRenameObjObj = createObject("component", "cfcomponents.ParentComp.Copy_and_Rename").init()>
<CFSET CopyRenameObjObj.Copy_and_Rename(DestinationLoc,SourceLoc,FileName)>
I created a copy and rename cfc:
<CFCOMPONENT>
<CFFUNCTION name="Init" access="public" returntype="any" output="false" hint="Returns an initialized component instance.">
<cfreturn THIS />
</CFFUNCTION>
<CFFUNCTION name="Copy_and_Rename">
<cfargument name="destinationPath" type="String" required="TRUE">
<cfargument name="SourcePath" type="String" required="TRUE">
<cfargument name="FileName" type="String" required="TRUE">
<!--- First copy the file from source location to destination location --->
<cffile action = "copy" destination = "#Trim(arguments.destinationPath)#"
source = "#Trim(arguments.SourcePath)#/#Trim(arguments.FileName)#"/>
<!--- Then move the file from the source to detination 2 --->
<cffile action = "move" destination = "/opt/coldfusion8/runtime/bin/"
source = "#Trim(arguments.SourcePath)#/#Trim(arguments.FileName)#"/>
<cffile action = "rename" destination = "/opt/coldfusion8/runtime/bin/#Trim(session.usergroup)#_PARENTLOADFeed.txt"
source = "/opt/coldfusion8/runtime/bin/#Trim(arguments.FileName)#"/>
</CFFUNCTION>
</CFCOMPONENT>
The error I'm getting is:
Despite of this error, the directory is there, the file is renamed, moved successfully but the process stop due to this error!
An exception occurred when performing a file operation copy on files
/space/users/www/data/temp/BC/BC_Smallfile.TXT and
/space/users/www/data /temp/Archives/BC/.
The cause of this
exception was: java.io.FileNotFoundException: /space
/users/www/data/temp/BC/BC_Smallfile.TXT (No such file or directory).
The error occurred in /space/users/www/webdocsec/cfcomponents /ParentComp/Copy_and_Rename.cfc: line 23
Problem code:
<!--- Source : /space/users/www/data/temp/BC/BC_testfile.TXT --->
<cffile action = "copy" destination =
"#Trim(arguments.destinationPath)#"
source = "#Trim(arguments.SourcePath)#/#Trim(arguments.FileName)#"/>
I'm running mach-ii v1.8 on my local machine with CF10 installed on Win7. I copied a site down from production (which works) and is throwing an error of which I am unable to search for much help on.
Expected structure key - received .; StructGet cannot be executed.
The error occurred in /web/frameworks/mach_1_8/caching/strategies/TimeSpanCache.cfc: line 413
Called from /web/frameworks/mach_1_8/caching/strategies/TimeSpanCache.cfc: line 233
411: <cffunction name="getStorage" access="private" returntype="struct" output="false"
412 : hint="Gets a reference to the cache data storage.">
413 : <cfreturn StructGet(getScope() & "." & getScopeKey()) />
414 : </cffunction>
The best source I found was this thread, but my MACHII_APP_KEY has no punctuation in it. Ideas?
<cfparam name="MACHII_APP_KEY" type="string" default="expoadmin" />
I'm trying to zip a directory using cfzip with no success. The newly created directory contains PDFs. The code:
<cfset tempDir = getTempDirectory() />
<cfset userDirName = CreateUUID() />
<cfset userTempDir = #tempDir# & #userDirName# />
<cfloop query="data">
Create PDFs...[cfdocument]
<cffile action="write" file="#userTempDir#\#name#.pdf" output="#pdf_output#" addnewline="no" nameconflict="makeunique" />
</cfloop>
<cfzip action="zip" source="#userTempDir#" file="#tempDir#/testZIP.zip" recurse="yes" />
Everything executed nicely but cfzip. When the cfzip line tries to execute the following error comes up:
The page you were executing caused an internal server error
Request /applications/useritems/resources-cors/cfScripts/Print/Print.cfc
File Trace E:/Tomcat/webapps/openbd/applications/useritems/resources-cors/cfScripts/Print/Print.cfc
Type Internal
Tag Context CFZIP (E:/Tomcat/webapps/openbd/applications/useritems/resources-cors/cfScripts/Print/Print.cfc, Line=1018, Column=13)
|
+-- CFIF (E:/Tomcat/webapps/openbd/applications/useritems/resources-cors/cfScripts/Print/Print.cfc, Line=818, Column=9)
|
+-- CFFUNCTION (E:/Tomcat/webapps/openbd/applications/useritems/resources-cors/cfScripts/Print/Print.cfc, Line=814, Column=5)
Stack Trace
java.lang.NullPointerException
at com.naryx.tagfusion.expression.function.file.Zip.execute(Unknown Source)
at com.naryx.tagfusion.cfm.tag.io.cfZIP.createZip(Unknown Source)
at com.naryx.tagfusion.cfm.tag.io.cfZIP.realRender(Unknown Source)
at com.naryx.tagfusion.cfm.tag.io.cfZIP.render(Unknown Source)
What am i missing here?
I am running the following command using ColdFusion's cfexecute: composite -geometry +2+2 "C:\Inetpub\wwwroot\isubscribe_uk\diomedes\www\images\newsletter\316\resized.png" "C:\Inetpub\wwwroot\isubscribe_uk\diomedes\www\images\newsletter\templateImages\isubscribe\blank.png" "C:\Inetpub\wwwroot\isubscribe_uk\diomedes\www\images\newsletter\316\part1.png"
<cffunction name="executeWrap" returntype="string">
<cfargument name="commandToRun" type="string" required="Yes">
<cfargument name="cmdArg" type="string" required="Yes">
<cfset var result = "">
<cfexecute name="#arguments.commandToRun#" arguments="#arguments.cmdArg#"
variable="result" timeout="15" />
<!--- <cfdump var="#arguments#">
<cfdump var="#result#"> --->
<cfreturn result>
</cffunction>
For some reason the above thing does not work. Though when I run the command directly onto the command prompt then it works.
Any ideas please?
CFExecute ignores anything sent to standard error by the called process. To be able to see if there is any error output generated, add the "errorVariable" argument to your cfexecute call, then check if there is anything there and let your script react accordingly.
<cfexecute name="..command to run..."
arguments='.. your arguments...'
variable="results"
errorVariable="errorOuptut"
></cfexecute>
<cfif len(errorOuptut)>
<cfthrow message="#errorOuptut#" />
</cfif>
More info here:
http://www.raymondcamden.com/index.cfm/2008/4/9/ColdFusion-801-change-to-CFEXECUTE