Sign in Join
FPDoc Onlineexperiment

fpSystem function

In unit Unix

Execute and feed command to system shell.

Declaration

pascal
function fpSystem(const Command: RawByteString): cint

Description

FpSystem invokes the bash shell ( /bin/sh), and feeds it the command Command (using the -c option). The function then waits for the command to complete, and then returns the exit status of the command in wait(3) format, or 127 if it could not complete the FpFork or FpExecve calls. To convert the return value of fpsystem to the real return value use WEXITSTATUS().

Errors

Errors are reported in (fpget)ErrNo

See also

Example: ex80

pascal
program example56;

uses Unix;

{ Program to demonstrate the Shell function }

Var S : Longint;

begin
  Writeln ('Output of ls -l *.pp');
  S:=fpSystem('ls -l *.pp');
  Writeln ('Command exited with status : ',S);
end.

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.