Execute a system command: Difference between revisions

Add NetRexx implementation
(Added COBOL example. Corrected PDP-11 heading.)
(Add NetRexx implementation)
Line 703:
<lang MUMPS>ZSY "ls"</lang></p>
<p>Note: $ZF in GT.M is Unicode version of $F[ind].</p>
 
=={{header|NetRexx}}==
{{Trans|Java}}
<lang NetRexx>/* NetRexx */
options replace format comments java crossref symbols binary
 
import java.util.Scanner
 
runSample(arg)
return
 
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method runSample(arg) private static
parse arg command
if command = '' then command = 'uname -mprsv'
do
say 'Executing command:' command
jprocess = Runtime.getRunTime().exec(command)
jscanner = Scanner(jprocess.getInputStream())
loop label scanning while jscanner.hasNext()
say jscanner.nextLine()
end scanning
catch ex = IOException
ex.printStackTrace()
end
return
</lang>
{{out}}
<pre>
$ java RExecSysCmd00
Executing command: uname -mprsv
Darwin 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64 i386
$ java RExecSysCmd00 find . -type d
Executing command: find . -type d
.
./log
./tmp
./tmp/dist
./tmp/dist/tmp
./tmp/dist/tmp/META-INF
./tmp/org
./tmp/org/rosettacode
./tmp/org/rosettacode/samples
</pre>
 
=={{header|Objective-C}}==
Anonymous user