{"id":15927685,"url":"https://github.com/jfrux/systemcommand","last_synced_at":"2026-05-16T09:03:10.637Z","repository":{"id":4967482,"uuid":"6125170","full_name":"jfrux/SystemCommand","owner":"jfrux","description":"An alternative to cfexecute for ColdFusion Developers. Originally written by Kevan Stannard","archived":false,"fork":false,"pushed_at":"2015-08-28T23:29:10.000Z","size":159,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-07T08:29:01.620Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"piwik/piwik","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jfrux.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-10-08T13:56:08.000Z","updated_at":"2015-08-28T23:25:23.000Z","dependencies_parsed_at":"2022-09-09T05:31:53.696Z","dependency_job_id":null,"html_url":"https://github.com/jfrux/SystemCommand","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jfrux%2FSystemCommand","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jfrux%2FSystemCommand/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jfrux%2FSystemCommand/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jfrux%2FSystemCommand/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jfrux","download_url":"https://codeload.github.com/jfrux/SystemCommand/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240540551,"owners_count":19817791,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-06T23:03:34.689Z","updated_at":"2025-11-18T09:04:33.371Z","avatar_url":"https://github.com/jfrux.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"SystemCommand\n=============\nAn alternative to cfexecute for ColdFusion Developers.\n\nMany thanks to Kevan Stannard for originally authoring the Java class.\n\n**NOTE: I've put this project here so I can extend development on it in some areas.**\n\n##Description\nTypically when you want to execute a system command you would use the cfexecute tag, but there are some situations when this may not be ideal such as when you want to capture both the 'standard output' and 'error output' streams of the system command.\nThis is a very simple to use utility that allows you to execute command line programs from within ColdFusion.\nAlthough this was developed specifically for ColdFusion developers to use, it is written entirely in Java.\n\n**Original details on the java class:**\nhttp://stannard.net.au/blog/index.cfm/2008/3/26/Executing-System-Commands-with-ColdFusion\n\n##Requirements\nTo use this utility you need\n* To be running ColdFusion 6.1 or higher\n* To be able to register Java .jar files with the ColdFusion administrator (or use a Java class loader utility).\n\n##Installation\n* Download the project zip file\n* Copy the .jar file into your project wherever you desire.\n* Download JavaLoader and load the jar file with JavaLoader.\n\n-or-\n\n* Download the project zip file\n* Copy the .jar file to your ColdFusion\\lib folder (for example, C:\\ColdFusion8\\lib)\n* Restart your ColdFusion service.\n* \n\n\n\n\n\nTypically when you want to execute a system command you would use the \u003ccfexecute\u003e tag, but there are some situations when this may not be ideal such as when you want to capture both the \"standard output\" and \"error output\" streams of the system command.\n\n###Standard Output Stream and Error Output Stream\n\nMany command line programs send output to two data 'streams':\na) Standard output stream\nb) Error output stream\n\nWhen you manually execute a program the command line information sent to either stream is simply displayed on the screen - there is no distinction which stream is being used.\n\n###Example\n\nFor example, suppose we execute the command to determine the version of java running on your system. You may execute the following command:\n\n`java -version`\n\nWhich on my machine results in:\n```\njava version \"1.6.0_03\"\n\nJava(TM) SE Runtime Environment (build 1.6.0_03-b05)\n\nJava HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode)\n```\n\nThe problem with \u003ccfexecute\u003e\n\nSuppose you execute the command above using using:\n\n```coldfusion\n\u003ccfexecute name=\"java\" arguments=\"-version\" timeout=\"1\" variable=\"output\" /\u003e\n\u003ccfoutput\u003e#output#\u003c/cfoutput\u003e\n```\n\nThis produces no output!\n\nWhat happened? \nWell, cfexecute can only capture output sent to the standard output stream, but not anything sent to the error output stream.\n\nIn this example, the `java -version` command sends all of its output to the error output stream (which seems a bit odd, but it came in useful for this example).\n\nSo how can we capture both the standard output and the error output streams?\n\nUsing a batch file wrapper\n\nOne method of capturing both streams is to put the command inside a batch file and send the two output streams to two files, then read them back in again:\n\nSuppose we have a file javaversion.bat with the content\n\n`java -version`\nThen we run the batch file (on a windows machine) as follows\n\n`javaversion.bat 1\u003estdout.txt 2\u003eerrout.txt`\nThis is just the syntax for capturing the standard output (stream 1) and error output (stream 2)\n\nThis will result in the creation of two files:\nstdout.txt which has no data.\nerrout.txt which has the version data.\n\nThe next step would be to read in the files just created to get the output data.\n\n###Using Java\n\nThe previous entry on executing system commands described a technique of using inline Java code within ColdFusion, but this technique does not work for all executables.\n\nThe problem is that the standard output and error output streams need to be read simultaneously rather than sequentially. We can use a small Java application to help us in achieving this.\n\n###Installation\n\n1. Download SystemCommand Component. This contains the Java source code and a systemcommand.jar file.\n\n2. Add the systemcommand.jar file to your \"Java class path\".\n\nThis is done by either\n\na) Copying the systemcommand.jar file to your C:\\ColdFusion8\\lib directory (or the equivalent lib directory for your version of ColdFusion).\n\nor\n\nb) Adding the systemcommand.jar file to your Java class path within the ColdFusion administrator,\n\n3. Restart the ColdFusion service so the new .jar file is picked up.\n\nUsage\n\nOnce the systemcommand.jar file has been successfully installed, it can be used from within ColdFusion.\n\nThe system command object is created using the command:\n\n\u003ccfset syscmd = createObject(\"java\",\"au.com.webcode.util.SystemCommand\").init()\u003e\nThis object has one function: execute(command,timeout).\n\n\u003ccfset result = syscmd.execute(command,timeout)\u003e\nThe parameters are:\n\ncommand\tThe full command string to execute.\ntimeout\t(Optional) A timeout in milliseconds. The process will be terminated when the timeout is reached and an Exception will be thrown. The default timeout is 10 seconds.\nReturn Value\n\nThe value returned from the execute() function is an object with the following functions:\n\ngetCommand()\tThe original command that was executed.\ngetStandardOutput()\tThe standard output produced by the command.\ngetErrorOutput()\tThe error output produced by the command.\ngetExitValue()\tAn integer value provided by the process that was executed. A value of zero usually indicates that all was fine. A non zero value usually indicates a problem occurred.\nExample\n\nA simple example of ColdFusion code to use the system command utility.\n\n\u003ccfset command = \"java -version\"\u003e\n\u003ccfset syscmd = createObject(\"java\",\"au.com.webcode.util.SystemCommand\").init()\u003e\n\u003ccfset result = syscmd.execute(command)\u003e\n\u003ccfoutput\u003e\n   Command: #result.getCommand()#\u003cbr /\u003e\n   ExitValue: #result.getExitValue()#\u003cbr /\u003e\n   Error Output: #result.getErrorOutput()#\u003cbr /\u003e\n   Standard Output: #result.getStandardOutput()#\u003cbr /\u003e\n\u003c/cfoutput\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjfrux%2Fsystemcommand","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjfrux%2Fsystemcommand","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjfrux%2Fsystemcommand/lists"}