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!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!peer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nx02.iad01.newshosting.com!newshosting.com!news-out.readnews.com!s09-01.readnews.com!not-for-mail X-Trace: DXC=RNgHGgG:dGYh=7;Md4]1[_[3OhcoN[H0PX44`8^\]>7Z8DHB_I2k0TP_WOU;SDD77T;5lRQ0PeXe\;bH^b Newsgroups: comp.lang.ada Subject: Re: Is there some way of calling a system command? Message-ID: <20131126192430.45ba47f3@lufsen.sandat.dyndns.org> References: <1150031952.347657.244910@i40g2000cwc.googlegroups.com> <78030be6-8fe4-4514-85fc-a2627507628f@googlegroups.com> X-Newsreader: Claws Mail 3.9.0 (GTK+ 2.24.8; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 7043f7b1.ngroups.net X-Received-Bytes: 2752 X-Received-Body-CRC: 3766934333 Xref: news.eternal-september.org comp.lang.ada:17793 Date: 2013-11-26T19:24:30+01:00 List-Id: Why not just GNAT.OS_Lib.spawn or GNAT.Expect.* ? /Persan On Tue, 26 Nov 2013 07:35:26 -0800 (PST) tolkamp wrote: > Op zondag 11 juni 2006 15:19:12 UTC+2 schreef > jimmaure...@worldnet.att.net: > > Aldebaran wrote: > > > I am a newbie Ada-programmer and need help with this topic. > > > In C one can launch a system command, for instance through > > > the following function. > > > > > > system("ls "); > > > > > > or in JAVA > > > > > > exec("ls"); > > > > > > Is there some similar way of calling a system command in ADA? > > > > The easiest way is to simply call the C system command. > > The example below was run on my Windows XP system. > > > > with Interfaces.C.Strings; > > use Interfaces.C.Strings; > > > > procedure System_Example is > > function System_Call(Command : Chars_Ptr) return > > Interfaces.C.Int; pragma Import(Convention => C, Entity => > > System_Call, External_Name => "system"); > > Rc : Interfaces.C.Int; > > > > begin > > Rc := System_Call(New_String("dir")); > > > > end System_Example; > > > > The important part of the example is the creation of a function > > specification I have named System_Call. That function specification > > take a parameter of Chars_Ptr, which corresponds to a C char *. > > The function specification is used as the Ada interface to the C > > system call. The compiler is notified of that association through > > the pragma Import. That pragma causes the compiler to link the C > > system command and call it whenever System_Call is called in the > > Ada code. > > > > Jim Rogers > > Thank you for your reaction. > For me this is not very understandable. > Where must I put the directory path to the executable? > Is this "dir" in Rc := System_Call(New_String("dir"));? >