Praveen S wrote: > Hi All, > I have a executable file at a particular location in the filesystem. From > root directory i run this exe. This exe will load a shared object from > another location (say /usr/lib). Now the shared object wants to read a > config file which is in the directory where the exe is located. How can it > get that path. > > Remember we are running the exe from the home directory and exe can be > located in /usr/bin directory. Now the shared objected which is loaded by > this exe needs the path /usr/bin . It is not the PWD(present working > directory). > > Please help. > > TIA
Most shells will set an environment variable indicating where the current user's home directory is. However, you should probably look at how other software handles this issue as it could be more complex than simply assuming some environment variable will exist. Gnome, KDE, Mozilla, OpenOffice, etc. all dump config files into the user's home directory and read them despite the binaries being located elsewhere. Their source code could be worth looking into. -- Thomas Hruska CubicleSoft President Ph: 517-803-4197 *NEW* MyTaskFocus 1.1 Get on task. Stay on task. http://www.CubicleSoft.com/MyTaskFocus/
