From: Will DeBeest on 16 Mar 2010 05:46 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 16 Mar 2010 06:59 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 17 Mar 2010 05:40 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
|
Pages: 1 Prev: Generating Valid examples for a list of Functions Next: Calling kernel.dll from Mathematica |