[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 426
  • Last Modified:

CFExecute results while an EXE is running

Greetings all,
        I'd like to know if there is a way I can have my executable return results during a CFExecute so that the user executing the can visually see the progress its making. If I understand this correctly, I want to have the CFExecute loop while this executable is running and return some results. Something similiar to the following......

<CFEXECUTE NAME="C:\blah.exe"
    OUTPUTFILE="C:\blah_progress.log"
    TIMEOUT="60">
</CFEXECUTE>

Does this look correct ? If the executable writes to blah_progress.log will CF pick it up and place it on the page while the timeout is waiting for the executable to finish ?

Suggestions are appreciated, thank you in advance
0
Computron
Asked:
Computron
  • 3
  • 2
  • 2
  • +1
1 Solution
 
JeffHowdenCommented:
The timeout attribute on <cfexecute> will force CF to wait for it to finish processing before continuing execution of the rest of the CF template.  If you need to read, parse and/or display the contents of blah_progress.log, then use <cffile> to read the contents of the file into a variable and do what you need to do:

<cfexecute ...>

<cfscript>
  blah_progress_output = '';
</cfscript>
<cfif FileExists("C:\blah_progress.log")>
  <cffile action="read" file="C:\blah_progress.log" variable="outout">
  <cfscript>
    blah_progress_output = Trim(output);
  </cfscript>
</cfif>

0
 
ComputronAuthor Commented:
Thanks for answering Jeff

So you are suggesting that I omit the timeout so it doesn't block CF, and just have CF continue to read this log for progress updates ?

The entire process will only take a minute at the most I would guess. How will CF know that my CF Execute is done ? Deelte the progress log and its over ?

Is this the best way to feed results back to a page from the EXE for the user to view an in progress scenario ?
0
 
JeffHowdenCommented:
I misread your question.  I don't think there's any way to output the results of the call to the <cfexecute> *as* it's happening.
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
RCorfmanCommented:
I would offer something that may not be worth the effort, but you can consider it. It is basically building on JeffHowden's 'proposal'.  If you have access to the program for modifications, change it to write some particular line at the end when it is completed, then redirect the output to a file and display the results in a loop, getting pieces of the file as they become available within a cffile loop... basically , read records and keep track of where you were at, then re-read and display more if it is available.

Do this in a loop. with a Pause in the loop, you can use this trick
http://www.experts-exchange.com/Web/WebDevSoftware/ColdFusion/Q_21686021.html
Maybe output more data every 10 seconds.

You can protect yourself from the program dying and not outputting all it's data by putting a counter in and only looping for X number of itterations (at 10 seconds each, or whatever, you can time it out to however long you want).

This would be dependent on knowing when the output is done from the program though via a special string or character... or, if you knew it output data pretty regularly, maybe you do a 5 second pause loop, and if there is no new data, you consider it done, or something similar...

As I said, it may not be worth it, but it could work reasonably well depending on your requirements and ability to modify what is in place.
0
 
ComputronAuthor Commented:
Thanks for the responses guys. I went about this a bit different as there just wasn't a clean way to accomplish this.
0
 
RCorfmanCommented:
I believe that the question was answered. The given answers provided methods to do this, or input on why it really isn't possible to do exactly what was originally requested.  It is my opinion that points should be allocated.
0
 
JeffHowdenCommented:
I agree with RCorfman, FWIW.
0
 
GranModCommented:
Closed, no 500 points refunded.
GranMod
The Experts Exchange
Community Support Moderator of all Ages
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now