I am trying to decrypt a CSV using Coldfusion. The CSV has been encrypted using gpg4win. I have created a scheduled task in CF Admin which checks a folder for the encrypted file and if found, decrypts it and stores the result in another folder as a CSV file (Which will then be imported into a DB).

This is an excerpt of the code:

<cfparam name="Variables.InputFolderName" default="inputfolder" />
<cfparam name="Variables.OutputFolderName" default="outputfolder" />
<cfparam name="gKeyPassphrase" default="sampletestkey" /> <!--- Passphrase for gpg encryption --->
<cfparam name="gEncryptionKeyID" default="sampletestid" /> <!--- Encryption iD --->

<cfset inputFilePath = ExpandPath("/resources/uploads/csv/#Variables.InputFolderName#") />

<cfset outputpath = ExpandPath("/resources/uploads/#Variables.OutputFolderName#") />

<cftry>
    <cfdirectory directory="#inputFilePath#" name="Variables.EncryptedCSVFiles" filter="*.gpg" action="list" >

    <cffile action="read" file="#inputFilePath#\#name#" variable="Variables.EncryptedCSVData" />

    <cfexecute name="C:\Program Files (x86)\GNU\GnuPG\gpg2" arguments="--passphrase=#gKeyPassphrase# --batch -o #inputFilePath# -d -r #gEncryptionKeyID# ouputfile=#outputpath#/test.csv" timeout="300"></cfexecute>

 <cfcatch type="any">
    <!--- I tried emailing a cfdump of the error to myself but it didn't work --->
 </cfcatch>
</cftry>

When I run the scheduler manually, the 'This scheduled task was completed successfully.' displays in CF Admin but the a decrypted file is not created and I don't get any error reporting email either.

Will be really grateful if anyone can help me out with this.

Thank you.

The scheduled task will point to a cfml file. Are you able to run the actual cfml file manually and if so do you see an error?

You might want to remove the try/catch block to see the error.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.