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.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!weretis.net!feeder1.news.weretis.net!news.roellig-ltd.de!open-news-network.org!cyclone03.ams2.highwinds-media.com!voer-me.highwinds-media.com!peer03.am1!peering.am1!peer02.fr7!news.highwinds-media.com!post02.fr7!fx22.fr7.POSTED!not-for-mail Subject: Re: pass a argument to spawn Newsgroups: comp.lang.ada References: From: Per Sandberg User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <%H1ly.559632$hA3.555852@fx22.fr7> X-Complaints-To: abuse@usenet.se NNTP-Posting-Date: Tue, 12 Jan 2016 07:12:59 UTC Organization: usenet.se Date: Tue, 12 Jan 2016 08:12:58 +0100 X-Received-Body-CRC: 2834788018 X-Received-Bytes: 2694 Xref: news.eternal-september.org comp.lang.ada:29098 Date: 2016-01-12T08:12:58+01:00 List-Id: Well An argument_list is an array of String_Access and needs to be initialize as such. ------------------------------------------------------------------------- with GNAT.OS_Lib; use GNAT.OS_Lib; with Ada.Text_IO; use Ada.Text_IO; procedure Console_Ada is State_Spawn : Boolean; Arg : constant Argument_List := (1 => new String'("-a")); -- Named association is needed since there is only one argument. -- This construct also leaks memory but that does not matter here -- since the program terminate immediate. begin Put_Line ("Print of your files :"); Spawn ("/bin/ls", Arg, State_Spawn); Put (" Execution of the program with Spawn ? : " & State_Spawn'Img); end Console_Ada; ------------------------------------------------------------------------- /May i also suggest that you look into the GNAT.Expect package. /Per Den 2016-01-12 kl. 02:17, skrev comicfanzine@gmail.com: > Hi , i'm trying to do a simple " ls -a " , on Ubuntu . > > I tried to associate a string value , because : > > subtype Argument_List is String_List; > > But it failed . > > Anyway , i'm lost with all the types and subtypes in GNAT.OS_Lib and System.Strings . > > So , i don't know how to proceed in the simplier way . > > WITH GNAT.OS_Lib ; USE GNAT.OS_Lib ; > WITH Ada.Text_IO ; USE Ada.Text_IO ; > > procedure console_Ada is > > state_spawn : boolean ; > > arg : Argument_List ( 1..1 ) ; > -- here the value must be "-a" . > > begin > > new_line ; > > put_line ( " Print of your files :") ; > > new_line ; > > Spawn ( "/bin/ls" , arg , state_spawn ); > -- /bin/ls -a > > new_line ; > > put ( " Execution of the program with Spawn ? : " & Boolean'Image( state_spawn ) ) ; > > end console_Ada ; >