Execute a system command: Difference between revisions

Add Emacs lisp solution
(Add Emacs lisp solution)
Line 398:
Because of a quirk in the implementation ([http://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmExecuteProcessCommand.cxx;hb=HEAD cmExecuteProcessCommand.cxx] and [http://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/kwsys/ProcessUNIX.c;hb=HEAD ProcessUNIX.c]), CMake diverts the standard output to a pipe. The effect is like running <code>ls | cat</code> in the shell. The ''ls'' process inherits the original standard input and standard error, but receives a new pipe for standard output. CMake then reads this pipe and copies all data to the original standard output.
 
''execute_process()'' can also chain commands in a pipelinepipeeline, and capture output.
 
<lang cmake># Calculate pi to 40 digits after the decimal point.
Line 482:
print(`failed to execute ls: $problem`)
}</lang>
 
=={{header|Emacs Lisp}}==
===Syncronous===
<lang Lisp>(shell-command "ls")</lang>
 
===Asyncronous===
<lang Lisp>(async-shell-command "ls")</lang>
 
=={{header|Erlang}}==