Sponsored Content
Top Forums Programming find the fully-qualified path for the app my module is running in Post 95350 by jim mcnamara on Tuesday 10th of January 2006 02:58:39 PM
Old 01-10-2006
There is no one perfect way to do this in Linux/Unix.

argv[0] may have it, unless the file was exec'd, getcwd() may be it, or
you can try a directory search.

This is because files can be run in a lot of different ways, and Linux does not have a registry.
 

10 More Discussions You Might Find Interesting

1. Programming

Need help with C app on Oracle running on Solaris 6

Hello, I would really appreciate some help with a problem my current client is having. He has an old legacy app that does his company's financial accounting and ERP for manufacturing, etc. The app was written by a company called "Just in time" in Austin, TX, and they are no longer in business. ... (2 Replies)
Discussion started by: w0lf
2 Replies

2. Solaris

Hostname not fully qualified..

Hi Friends.. I have a small problem with the hostname of my system.I had installed Solaris 10 X86 on Vmware in my windows 2000 system.After booting of my solaris system,if i give check-hostname command it says ,, hostname is not fully qualified ,,change the hostname to hostname.xxx.xxxxxx.com... (3 Replies)
Discussion started by: sdspawankumar
3 Replies

3. Programming

Running app after logout and monitoring

Hello! I just programmed a very simple app, it's function is to report every minute the state of the memory and cpu and put it to and xml. All this stuff is working ok since I'm logged in into the machine, but i want it to run as a service, how can I do that?? P.S: Any one knows how can I... (1 Reply)
Discussion started by: ncatdesigner
1 Replies

4. IP Networking

Unable to ping freebsd machine using fully qualified domain name

hi all. am unable to ping a freebsd machine using fully qualified domain name from a windows machine. i have already set the fqdn for the machine. plz advise me. thanks. (2 Replies)
Discussion started by: coolatt
2 Replies

5. Windows & DOS: Issues & Discussions

Display running 'app' in terminal titlebar?

Hi. I was, not too long ago, an OS X home user. One of the things I remember from using the Apple-installed Terminal is: whenever an executable that took more than a split second to do its thing was running, its name would appear in the title bar in a way similar to "Terminal: ssh" or "Terminal:... (0 Replies)
Discussion started by: SilversleevesX
0 Replies

6. Shell Programming and Scripting

how to get fully qualified path name

hi actually i want to get fully qualified path name of the file when the file name is entered as command line argument while running a shell script ex. if i run the shell as $./test.sh ./nsdnet_file.csv the it should display me the full path of the file like /dialp/Release/bin/nsdnet_file.csv... (3 Replies)
Discussion started by: priyanka3006
3 Replies

7. AIX

AIX 6.1 app running on 5.x?

Hi, A quick question. If I build an application on AIX 6.1 TL3 using XL C/C++ 8.0 and Oracle 10g, can I then take those binaries and run them on AIX 5.3 and previous? Regards Kevin (3 Replies)
Discussion started by: KevB
3 Replies

8. Solaris

Can't change fully qualified host name

I tried changing my /etc/inet/hosts file for my server to: <ip address> <hostname> <fqdn> but when I go to reboot the file changes right back to: <ip address> <hostname> how do I get the <fqdn> to stick on a reboot. Thanks (2 Replies)
Discussion started by: jastanle84
2 Replies

9. Programming

Running bin file from a module

Hi I actually wrote a simple module and I need to call a bin file from that module. Could you give me some hints how to do that? (I tried with stdlib.h and 'system()', but cannot call that function from a module). Regards. (28 Replies)
Discussion started by: Chrisdot
28 Replies

10. UNIX for Dummies Questions & Answers

How to fix Python path for some script/app?

Hello, i have: # python -V Python 2.7.6 But original for my CentOS is 2.3 or 2.4 my python folder: /root/python2.7.6 (inside are folders like lib, include, bin, share) I launched app iotop: # iotop -od 6 Traceback (most recent call last): File "/usr/bin/iotop", line 16, in... (3 Replies)
Discussion started by: postcd
3 Replies
GETCWD(3)						     Linux Programmer's Manual							 GETCWD(3)

NAME
getcwd, get_current_dir_name, getwd - Get current working directory SYNOPSIS
#include <unistd.h> char *getcwd(char *buf, size_t size); char *get_current_dir_name(void); char *getwd(char *buf); DESCRIPTION
The getcwd() function copies an absolute pathname of the current working directory to the array pointed to by buf, which is of length size. If the current absolute path name would require a buffer longer than size elements, NULL is returned, and errno is set to ERANGE; an appli- cation should check for this error, and allocate a larger buffer if necessary. If buf is NULL, the behaviour of getcwd() is undefined. As an extension to the POSIX.1 standard, Linux (libc4, libc5, glibc) getcwd() allocates the buffer dynamically using malloc() if buf is NULL on call. In this case, the allocated buffer has the length size unless size is zero, when buf is allocated as big as necessary. It is possible (and, indeed, advisable) to free() the buffers if they have been obtained this way. get_current_dir_name, which is only prototyped if _GNU_SOURCE is defined, will malloc(3) an array big enough to hold the current directory name. If the environment variable PWD is set, and its value is correct, then that value will be returned. getwd, which is only prototyped if _BSD_SOURCE or _XOPEN_SOURCE_EXTENDED is defined, will not malloc(3) any memory. The buf argument should be a pointer to an array at least PATH_MAX bytes long. getwd does only return the first PATH_MAX bytes of the actual pathname. Note that PATH_MAX need not be a compile-time constant; it may depend on the filesystem and may even be unlimited. For portability and security rea- sons, use of getwd is deprecated. RETURN VALUE
NULL on failure with errno set accordingly, and buf on success. The contents of the array pointed to by buf is undefined on error. ERRORS
EACCES Permission to read or search a component of the file name was denied. EFAULT buf points to a bad address. EINVAL The size argument is zero and buf is not a null pointer. ENOENT The current working directory has been unlinked. ERANGE The size argument is less than the length of the working directory name. You need to allocate a bigger array and try again. NOTES
Under Linux, the function getcwd() is a system call (since 2.1.92). On older systems it would query /proc/self/cwd. If both system call and proc file system are missing, a generic implementation is called. Only in that case can these calls fail under Linux with EACCES. These functions are often used to save the location of the current working directory for the purpose of returning to it later. Opening the current directory (".") and calling fchdir(2) to return is usually a faster and more reliable alternative when sufficiently many file descriptors are available, especially on platforms other than Linux. CONFORMING TO
POSIX.1 SEE ALSO
chdir(2), fchdir(2), open(2), unlink(2), free(3), malloc(3) GNU
2002-04-22 GETCWD(3)
All times are GMT -4. The time now is 06:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy