From: Will DeBeest on
When using notebooks I can use NotebookDirectory[] to return a string
for the notebook path. Unless I've missed something obvious there
doesn't appear to be a way of automatically finding directories if you
are running *.m files remotely from a terminal. Basically I have an
*.m file and I'd like to have something like MFileDirectory[] so that
the path is identified when the file is run remotely. It seems simple/
obvious. Any ideas?

From: Albert Retey on
Am 16.03.2010 10:46, schrieb Will DeBeest:
> When using notebooks I can use NotebookDirectory[] to return a string
> for the notebook path. Unless I've missed something obvious there
> doesn't appear to be a way of automatically finding directories if you
> are running *.m files remotely from a terminal. Basically I have an
> *.m file and I'd like to have something like MFileDirectory[] so that
> the path is identified when the file is run remotely. It seems simple/
> obvious. Any ideas?

AFAIK there is nothing likte NotebookDirectory for package files. But
you can create something with $Input, FindFile and FileNames. E.g. I
think this should work in many cases:

FindFile[$Input]

but it might depend on how you start the .m file so you might need to
experiment to get the desired result. You might also want to look at the
tutorial tutorial/NamingAndFindingFiles for more functions related to
the topic.

hth,

albert


From: Carl K. Woll on
On 3/16/2010 6:58 AM, Albert Retey wrote:
> Am 16.03.2010 10:46, schrieb Will DeBeest:
>
>> When using notebooks I can use NotebookDirectory[] to return a string
>> for the notebook path. Unless I've missed something obvious there
>> doesn't appear to be a way of automatically finding directories if you
>> are running *.m files remotely from a terminal. Basically I have an
>> *.m file and I'd like to have something like MFileDirectory[] so that
>> the path is identified when the file is run remotely. It seems simple/
>> obvious. Any ideas?
>>
> AFAIK there is nothing likte NotebookDirectory for package files. But
> you can create something with $Input, FindFile and FileNames. E.g. I
> think this should work in many cases:
>
> FindFile[$Input]
>
> but it might depend on how you start the .m file so you might need to
> experiment to get the desired result. You might also want to look at the
> tutorial tutorial/NamingAndFindingFiles for more functions related to
> the topic.
>
> hth,
>
> albert
>
>
There is System`Private`$InputFileName, but as the name indicates, this
functionality may change or be renamed at any time.

Carl Woll
Wolfram Research