>> Use the command "pwd". > > Nope. That tells me where the user is, not where the shell script is. > > Are you sure? If you do say, > > SCRIPT_DIR=`pwd` > echo "$SCRIPT_DIR" > > the echo should return the directory the script ran in.
100% sure. keybounceMBP:Applications michael$ pwd /Users/michael/Applications keybounceMBP:Applications michael$ cat ~/bin/testdir #!/bin/sh pwd SCRIPT_DIR=`pwd` echo "$SCRIPT_DIR" keybounceMBP:Applications michael$ testdir /Users/michael/Applications /Users/michael/Applications keybounceMBP:Applications michael$ I want it to return my ~/bin directory in this case. >> On Sun, Jul 21, 2013 at 4:16 PM, Michael <[email protected]> wrote: >> I feel silly for asking this. But I just realized I don't try this very >> often. >> >> Is there a way for a shell script to find itself? Or more precisely, the >> directory it is in? >> >> I am trying to run a program that wants an ini file specified on the command >> line; but it defaults to the assumption of having its config file in /etc >> unless you tell it where it is. And rather than a one-line script that hard >> codes a directory, I'd rather that it (the script) can tell where it is >> located, to use an ini file there. >> >> (Yea, a one-line script to just pass a config file argument to a program.) >> >> --- >> This message was composed with the aid of a laptop cat, and no mouse >> >> _______________________________________________ >> MacOSX-talk mailing list >> [email protected] >> http://www.omnigroup.com/mailman/listinfo/macosx-talk >> >> >> >> -- >> Best Regards, >> >> John Musbach > > --- > This message was composed with the aid of a laptop cat, and no mouse > > > > > -- > Best Regards, > > John Musbach --- This message was composed with the aid of a laptop cat, and no mouse
_______________________________________________ MacOSX-talk mailing list [email protected] http://www.omnigroup.com/mailman/listinfo/macosx-talk
