The Ada Program: os.adb

  1 -- osa.adb:  illustrate GNAT's hooks to underlying operating system
  2 with GNAT.OS_Lib; use GNAT;
  3 with Ada.Text_IO; use Ada;
  4 
  5 procedure OS is
  6    Long  : OS_Lib.String_Access := new String' ("-l");
  7    Args  : OS_Lib.Argument_List := (1=>Long);
  8    Result: Boolean;
  9 begin
 10    -- standard output directed to Ada program's standard output
 11    OS_Lib.Spawn ("/bin/ls", Args, Result);
 12 
 13    Text_IO.Put_Line (OS_Lib.Getenv ("HOME").all);
 14 
 15    OS_Lib.OS_Exit (0);
 16 end OS;