RosettaCodeData/Task/Execute-a-system-command/NetRexx/execute-a-system-command.ne...

24 lines
979 B
Plaintext

/* NetRexx */
options replace format comments java crossref symbols binary
import java.util.Scanner
runSample(arg)
return
-- 10:43, 27 August 2022 (UTC)10:43, 27 August 2022 (UTC)10:43, 27 August 2022 (UTC)10:43, 27 August 2022 (UTC)10:43, 27 August 2022 (UTC)10:43, 27 August 2022 (UTC)10:43, 27 August 2022 (UTC)10:43, 27 August 2022 (UTC)10:43, 27 August 2022 (UTC)10:43, 27 August 2022 (UTC)10:43, 27 August 2022 (UTC)10:43, 27 August 2022 (UTC)10:43, 27 August 2022 (UTC)10:43, 27 August 2022 (UTC)10:43, 27 August 2022 (UTC)~~
method runSample(arg) private static
parse arg command
if command = '' then command = 'ls -oa' -- for Windows change to: 'cmd /C dir'
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