comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: Trying to run ls, pwd, rm, etc. in linux without specifying the exact path
Date: Wed, 09 Mar 2016 17:55:27 +0000
Date: 2016-03-09T17:55:27+00:00	[thread overview]
Message-ID: <lyziu7zgc0.fsf@pushface.org> (raw)
In-Reply-To: d97b94b2-6a7e-4966-9563-daa20bd0173d@googlegroups.com

John Smith <yoursurrogategod@gmail.com> writes:

> I found this little example and expanded on it:
> http://rosettacode.org/wiki/Execute_a_system_command#Ada
>
> I used the example where GNAT.OS_Lib is used.  Everything works like I
> want it to, almost.  If I want to call a Linux command, I have to
> specify the exact path to it /bin/ls.  How can I import the various
> Linux environment variables so tha I can just call 'ls' without
> specifying the direct path to the binary?

I think Locate_Exec_On_Path ("ls") should do the trick.

   --  Try to locate an executable whose name is given by Exec_Name in the
   --  directories listed in the environment Path. If the Exec_Name does not
   --  have the executable suffix, it will be appended before the search.
   --  Otherwise works like Locate_Regular_File below. If the executable is
   --  not found, null is returned.
   --
   --  Note that this function allocates memory for the returned value. This
   --  memory needs to be deallocated after use.


      reply	other threads:[~2016-03-09 17:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-09 17:05 Trying to run ls, pwd, rm, etc. in linux without specifying the exact path John Smith
2016-03-09 17:55 ` Simon Wright [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox