1

I'm new to ColdFusion so please forgive me if I'm asking an obvious question.

I'm trying to run a simple code, which I've found somewhere to test if cfexecute works or not.

<cfexecute name="netstat" variable="result" timeout=10 />
<cfdump var="#result#">

The above code return [empty string], or if I try to write it into a file it just creates an empty file.

I've also tried to ping a server, what I can do from command line.

What I've noticed is that the page gets generated immediately instead of waiting for the timeout in case it would fail.

Also what is important to note: the code works sometimes, without changing anything.

Is it possible that there is a limitation on how many programs can ColdFusion execute?

Thanks for the help!

Solution: I had too many executions that did not terminate themselves automatically. That did not allow ColdFusion to open a new one.

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
Grabofus
  • 1,924
  • 14
  • 17
  • 3
    `name` attribute of `cfexecute` expects absolute path. [Docs](http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7d56.html) : `Absolute path of the application to execute.` If `netstat` is a variable then wrap it with pound(`#`). – Abhishekh Gupta Nov 12 '15 at 12:25
  • 2
    Why did someone vote to close this as "off topic"? The problem is clearly defined, the question includes a standalone repro case as well as the actual and expected results. – Leigh Nov 12 '15 at 15:07

1 Answers1

0

The issue is due to low timeout value. Execution of netstat command takes time. Try increasing it to 100 or more. I also experienced same issue. Increasing the timeout value solves the issue.

Note: as @beginner suggested you need to provide Absolute path of the executable to execute, in case the path is not added to your environment variable or default app folders (where os looks for the files by default). In case the path is available in environment variable or app folders you can just provide name too.

Pankaj
  • 1,731
  • 1
  • 13
  • 15
  • @Beginner I've updated my code to the following: Still having the same issue. – Grabofus Nov 12 '15 at 12:45
  • What happens when you try the code? Since the executable is in system folder, you can just pass its name too. – Pankaj Nov 12 '15 at 12:49
  • I've tried with absolute path and just netstat but in both cases it only returns [empty string]. Just to make sure it finds the file I changed it to a made-up name in which case it did generate an error. So it seems like it finds the file but for some reason it doesn't execute it. (I'm assuming it doesn't execute it because even if I run a ping which should take at least a couple seconds to execute, it always responds with [empty string] immediately). – Grabofus Nov 12 '15 at 13:07
  • @BaloghGábor - 1) Check the Task Manager to see if there any instances of netstat.exe or ping.exe left running. 2) FYI, early versions of CF did not capture the stderr stream which sometimes caused issues. 3) I always used both [`/c` (run and terminate) and `2>&1` (redirect stderr)](http://stackoverflow.com/questions/1002025/how-do-i-keep-cfexecute-from-hanging-after-a-printstacktrace/1002585#1002585) to avoid potential issues with cfexecute on CF8 and earlier. I suspect `/c` is what you need here. – Leigh Nov 12 '15 at 13:38
  • @Leigh That solved the issue! I experimented with wmic before seems like that one did not close down.. I logged into our webserver and there were around 50 of them running at the same time. After killing them one by one cfexecute works again. Thanks for the help everyone! – Grabofus Nov 12 '15 at 14:00
  • @BaloghGábor - I remember struggling with that same issue back in C8. It was like a lightbulb went on when I found out about those two flags ;-) Glad you got it working. BTW, since there's already an existing answer for this issue, I'm going to close this one as a "duplicate". – Leigh Nov 12 '15 at 15:03