program p
integer :: i
callexecute_command_line("x a b", exitstat=i)
print *, "Exit status of x was ", i
callexecute_command_line("x a b", wait=.false.)
print *, "running x in the background"endprogram p
import System.Process
spawnProcess x ["a","b"]
Assuming that x is a filepath to the program to run.
const { exec } = require('child_process');
exec(`${x} a b`);
This assumes a node.js environment.
See the documentation for examples on how to capture output, and equivalent synchronous commands.
var
p: tprocess;
begin
p.Executable := 'program_x';
p.Parameters.Add('a');
p.Parameters.Add('b');
p.Execute;
end.
tprocess is specific to freepascal and offers a cross-platform solution to this problem. In Delphi use shellexecute(), which is a windows only solution.
program p
integer :: i
call execute_command_line("x a b", exitstat=i)
print *, "Exit status of x was ", i
call execute_command_line("x a b", wait=.false.)
print *, "running x in the background"
end program p