This language bar is your friend. Select your favorite languages!

Idiom #111 Launch other program

From current process, run program x with command-line parameters "a", "b".

#include <stdlib.h>
int system("x a b");
using System.Diagnostics;
string[] args = { "a", "b"};
Process.Start(x, string.Join(" ", args));
import std.process;
spawnProcess([x, "a", "b"]);
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 
import "os/exec"
err := exec.Command("x", "a", "b").Run()
import System.Process
spawnProcess x ["a","b"]
const { exec } = require('child_process');
exec(`${x} a b`);
exec($x . " a b");
uses process;
var
  p: tprocess;
begin
  p.Executable := 'program_x';
  p.Parameters.Add('a');
  p.Parameters.Add('b');
  p.Execute;
end.
system $x, 'a', 'b';
import subprocess
subprocess.call(['x', 'a', 'b'])
`x a b`
use std::process::Command;
let output = Command::new("x")
    .args(&["a", "b"])
    .spawn()
    .expect("failed to execute process");

Do you know the best way to do this in your language ?
New implementation...

Idiom created by

programming-idioms.org