LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-16-2003, 10:45 AM   #1
codeblue
LQ Newbie
 
Registered: Oct 2003
Posts: 2

Rep: Reputation: 0
Determine Executable Starting Directory


In Linux, how does one determine the starting directory for an executable? In Win32, the analogous function would be GetModuleFileName(), which returns the path to the executable image. Is there a way to do the same, either from a shell script, Java, or C/C++ program?
 
Old 10-16-2003, 02:13 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Welcome to LQ.

Just look at the output from "pwd" or the bash varliable "$PWD".
 
Old 10-16-2003, 02:17 PM   #3
jharris
Senior Member
 
Registered: May 2001
Location: Bristol, UK
Distribution: Slackware, Fedora, RHES
Posts: 2,243

Rep: Reputation: 47
To follow on from david_ross - if you're working in C you could used getcwd() (see man getcwd for more info).

HTH and welcome to LinuxQuestions from me too!

cheers

Jamie...
 
Old 10-16-2003, 06:04 PM   #4
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Quote:
In Linux, how does one determine the starting directory for an executable?
Or do you actually mean how a program can find the directory where the executable of the program is in? Then see this thread:

http://www.linuxquestions.org/questi...threadid=92303
 
Old 10-17-2003, 10:11 AM   #5
codeblue
LQ Newbie
 
Registered: Oct 2003
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks! That's what I needed.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to determine # files in a directory ElricM Linux - Newbie 9 01-24-2012 02:37 PM
Determine os install directory Jebrew Linux - Software 2 08-12-2005 10:48 PM
Bash scripting and trying to determine whether a directory exists? obelxi Programming 9 04-18-2005 11:22 PM
wine: cannot determine executable type for L"Y:\\.wine\\aforce.exe" jimsproch Linux - Software 0 02-04-2005 07:13 PM
trying to determine the size of all files in a directory riddlebox80 Programming 7 06-11-2003 07:27 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration