<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>joel&#39;s thoughts &#187; ColdFusion</title>
	<atom:link href="http://joel.fouse.net/category/coldfusion/feed/" rel="self" type="application/rss+xml" />
	<link>http://joel.fouse.net</link>
	<description>random musings of a bleeding-heart conservative geek</description>
	<lastBuildDate>Thu, 20 May 2010 19:29:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Odd cfexecute behavior</title>
		<link>http://joel.fouse.net/2005/05/06/odd-cfexecute-behavior/</link>
		<comments>http://joel.fouse.net/2005/05/06/odd-cfexecute-behavior/#comments</comments>
		<pubDate>Fri, 06 May 2005 14:53:26 +0000</pubDate>
		<dc:creator>joel</dc:creator>
				<category><![CDATA[ColdFusion]]></category>

		<guid isPermaLink="false">http://joel.fouse.net/wp/2005/05/06/odd-cfexecute-behavior/</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p>This probably won&#8217;t mean much to most folks who stop by here on a regular basis, but I put it up mostly in the hopes that it might be useful to someone out there trying to figiure out what their code is doing.</p>
<p>We use ColdFusion in one of our projects at work, and we&#8217;re still stuck on CF 5.  I&#8217;ve been tinkering with writing a few custom tags to make use of the excellent <a href="http://www.sysinternals.com/ntw2k/freeware/pstools.shtml" target="_new">PsTools</a> package from <a href="http://www.sysinternals.com/" target="_new">SysInternals</a> using the cfexecute tag, and I&#8217;ve discovered a few interesting things about cfexecute.</p>
<p>First of all, the obvious annoyance &#8212; in CF 5, cfexecute doesn&#8217;t provide a handy way to capture any output in a variable.  You either give it an output file or it will display its output to the generated page, which means the only way to capture it in a variable is to wrap the cfexecute call in a cfsavecontent tag (this has been fixed in CFMX 6.1, which adds a &#8216;variable&#8217; attribute to the cfexecute tag).  But hey, I can live with that.  It&#8217;s not clean, but it works.</p>
<p>The next interesting thing is that cfexecute will take the first output it receives and finish executing, <i>regardless of whether the called command is complete</i>.  For example, the first PsTools command I wanted to integrate was Psinfo, to find out things like the system&#8217;s uptime.  When you run Psinfo, it displays a few lines of copyright info and pauses while it queries the system for information.  Cfexecute will grab this initial output and return, ignoring anything else the process might return.  Which, among other things, means it&#8217;s not waiting for an exit code from the command.  In this case I was able to get around it because the initial output from Psinfo is apparently on StdErr rather than StdOut.  So I made a batch file that calls Psinfo and pipes StdErr to a temp file (does Windows have anything like /dev/null?), and then deletes the temp file.  Cfexecute then calls the batch file (actually it calls &#8216;c:\windows\system32\cmd.exe /c psinfo.bat&#8217;) and receives the correct output, which I then chop up and stuff into a struct for later use.</p>
<p>However, I encountered this two days ago, and I tried to reproduce the problem set just now to make sure I wasn&#8217;t crazy.  Unfortunately I may have strongly suggested the opposite because I can&#8217;t reproduce it, so YMMV.  This is maddening&#8230;</p>
<p>Anyway, the next one I <i>am</i> sure of, which is that when cfexecute is capturing and returning the output (rather than piping it to a file using the &#8216;outputFile&#8217; attribute) there is a 4Kb (which is to say, 4096 character) limit on how much it can hold.  The effect when running a command that returns more than that (like, say, pslist) is that cfexecute will fill up its buffer, wait until its timeout has expired, and throw a timeout error (which you can, of course, cfcatch), leaving the actual command running indefinitely, waiting to give the rest of its output to someone who isn&#8217;t listening anymore.  This too has been fixed in CFMX, but for CF 5 it seems the only answer is to use cfexecute w/ outputFile, followed by a cffile read and a cffile delete.  Talk about ugly&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://joel.fouse.net/2005/05/06/odd-cfexecute-behavior/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
