Logo

Programming-Idioms

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

Implementation edit is for fixing errors and enhancing with metadata. Please do not replace the code below with a different implementation.

Instead of changing the code of the snippet, consider creating another Haskell implementation.

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please do not paste any copyright violating material.

Please try to avoid dependencies to third-party libraries and frameworks.

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