Execute a system command: Difference between revisions

no edit summary
(Added PicoLisp)
No edit summary
Line 13:
Ret_Val := Sys(To_C("ls"));
end Execute_System;</lang>
 
=={{header|Aikido}}==
The simplest way to do this is using the <code>system()</code> function. It returns a vector of strings (the output from the command).
<lang aikido>
var lines = system ("ls")
foreach line lines {
println (line)
}
</lang>
If you don't want to process the output you can use the <code>exec</code> function. It writes the output to the standard output stream by default;
<lang aikido>
exec ("ls")
</lang>
You also have the regular <code>fork</code> and <code>execv</code> calls available:
<lang aikido>
var pid = fork()
if (pid == 0) {
var args = ["/bin/ls"]
execv ("/bin/ls", args)
exit(1)
}
var status = 0
waitpid (pid, status)
 
</lang>
 
=={{header|ALGOL 68}}==