Results 1 to 6 of 6

Thread: Unix path for an executable

  1. #1
    Join Date
    Aug 2010
    Posts
    41

    Unix path for an executable

    Hello,
    I encountered a problem and I can not solve it (especially as a portable solution would be appreciated). I wants to know the absolute path of the executable being (hint written in C on Unix). I arrive without problem getting the directory work, the name on the command line, find this {|@|^ \ @ | path of the executable? Any more discussion on this topic is appreciated.

  2. #2
    Join Date
    Apr 2008
    Posts
    2,276

    Re: Unix path for an executable

    Hey,
    There is no portable method, and sometimes the information is not even available. He must also see that someone can load your code without calling exec (2), so the path the executable does not necessarily make sense. You can use argv [0] $ PATH and browse and if argv [0] does not contain "/". It will work in most cases. Under Linux, readlink ("/ proc / self / exe");

  3. #3
    Join Date
    Aug 2010
    Posts
    41

    Re: Unix path for an executable

    It will not work for me (the test must also be able running on OpenVMS), or it will have to write a routine by system or type of systems. That's true, but it is something that only works on Linux. I will play with it for some more time and then post back with the difficulty I am facing.

  4. #4
    Join Date
    May 2008
    Posts
    2,945

    Re: Unix path for an executable

    And even if the information is available, it may not have any sense. For example, if the executable has been removed from its location. It is a pretty common case where a machine makes updates. I guess I am correct here. Thank you.

  5. #5
    Join Date
    Aug 2008
    Posts
    721

    Re: Unix path for an executable

    I have no idea on linux based operating systems but the equivalent on Solaris is as follows :
    Code:
    sprintf (path, "/ proc /% d / path / a.out", getpid ());
    readlink (path, buf, size);

  6. #6
    Join Date
    Aug 2010
    Posts
    41

    Re: Unix path for an executable

    Knowing that I seek in this application that the executable, I am not sure whether this executable is still on the disk) I am looking for a way of saying that if my executable / a / b / c / executable, it should launch a preprocessor that is / a / b / c / preprocessor (not not trusting the PATH), is it possible to imagine a piece of code to retrieve the path. For now, I coded the thing hard with an option in the configure script, but it pleases me that medium. I can not use the PATH variable as it can find Official _before_ preprocessor preprocessor and causes a hole security.

Similar Threads

  1. How to open UNIX executable files in Final Cut
    By Lares in forum Operating Systems
    Replies: 6
    Last Post: 24-01-2011, 07:00 AM
  2. Opening UNIX Executable Files in the OS X
    By Mithras in forum Operating Systems
    Replies: 6
    Last Post: 15-11-2010, 08:52 AM
  3. Folders automatically turns into Unix Executable Files
    By Wasan in forum Windows Software
    Replies: 3
    Last Post: 10-11-2010, 05:53 AM
  4. UNIX Executable File not opening
    By himeshRES in forum Operating Systems
    Replies: 3
    Last Post: 10-11-2010, 01:17 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,751,844,138.15811 seconds with 16 queries