From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3d0e3853cc52ad5 X-Google-Attributes: gid103376,public From: Samuel Tardieu Subject: Re: help about execute a command Date: 1998/08/07 Message-ID: #1/1 X-Deja-AN: 378812570 References: <6qddcf$2mr$1@nnrp1.dejanews.com> Mail-Copies-To: sam@ada.eu.org Content-Type: text/plain; charset=US-ASCII Organization: TELECOM Paris Mime-Version: 1.0 (generated by tm-edit 7.108) Newsgroups: comp.lang.ada Date: 1998-08-07T00:00:00+00:00 List-Id: > I am learning ADA 95 with gnat 3.10 under linux, and I must write a > program that executes a command of the operating system such as > ls,insmod , cp ... Is that possible ? Thanks in advance ! This is really a FAQ... Here is an untested version of a function (Spawn) which does this in Ada[1]. Sam Footnotes: [1] Note the capitalization, it's not ADA -- Samuel Tardieu -- sam@ada.eu.org function Spawn (Command : String) return Integer; -- Spawn a command and return its exit status with Interfaces.C.Strings; use Interfaces.C, Interfaces.C.Strings; function Spawn (Command : String) return Integer is function C_System (Command : chars_ptr) return int; pragma Import (C, C_System, "system"); C_Command : chars_ptr := New_String (Command); Code : constant int := C_System (C_Command); begin Free (C_Command); return Integer (Code / 256); end Spawn;