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=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!attcan!uunet!samsung!think.com!linus!linus!emery From: emery@linus.mitre.org (David Emery) Newsgroups: comp.lang.ada Subject: Re: Making EXECL Unix call from Ada Message-ID: Date: 10 Dec 90 15:51:04 GMT References: <10048@jarthur.Claremont.EDU> Sender: usenet@linus.mitre.org Followup-To: comp.lang.ada Distribution: na Organization: The Mitre Corporation, Bedford, MA In-reply-to: cstein@jarthur.claremont.edu's message of 9 Dec 90 19:38:55 GMT List-Id: I suspect the problem is that Unix is running off the end of your string and/or your parameter list. Try the following: with system; -- assumed to provide the object "null_address" -- (also known as "address_zero" or "no_addr" on some compilers) with text_io; procedure print function execl (name : system.address; arg0 : system.address; arg1 : system.address) -- all we need return integer; -- assumed to be the same size as C "int" pragma interface (C, execl); program_name : constant string := "/usr/local/bin/enscript" & Ascii.nul; file_name : constant string := "/hmc2/guests/lsdada/cliffie/hello" & Ascii.nul; status : integer; begin status := execl (name => program_name(program_name'first)'address, arg0 => file_name(file_name'first)'address, arg1 => system.null_address); if status/=0 then put_line("True."); else put_line("False"); end if; end print; Remember, that in C strings are null-terminated, and represented by the address of the first element. Also, from the C definition of the parameters for execl, the last parameter is of type "address", with value 0, not the address of an object with value 0. There's a subtle difference, in that the former is "0", and the latter is not "0", but some (non-zero) address. Here are the changes to print a user-supplied file. Append a null to the end of the user-supplied string, and pass this to C: procedure print (file_to_print : string) is ... file_name : constant string := file_to_print & Ascii.nul; ... end print; dave emery emery@aries.mitre.org