Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 23-08-2010
Member
 
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.
Reply With Quote
  #2  
Old 23-08-2010
Member
 
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");
Reply With Quote
  #3  
Old 23-08-2010
Member
 
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.
Reply With Quote
  #4  
Old 23-08-2010
Member
 
Join Date: May 2008
Posts: 2,944
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.
Reply With Quote
  #5  
Old 23-08-2010
Member
 
Join Date: Aug 2008
Posts: 718
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);
Reply With Quote
  #6  
Old 23-08-2010
Member
 
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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Unix path for an executable"
Thread Thread Starter Forum Replies Last Post
How to open UNIX executable files in Final Cut Lares Operating Systems 6 24-01-2011 07:00 AM
Opening UNIX Executable Files in the OS X Mithras Operating Systems 6 15-11-2010 08:52 AM
Folders automatically turns into Unix Executable Files Wasan Windows Software 3 10-11-2010 05:53 AM
UNIX Executable File not opening himeshRES Operating Systems 3 10-11-2010 01:17 AM


All times are GMT +5.5. The time now is 06:29 PM.