MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: Running the kernel command line with additional input files

  • To: mathgroup at smc.vnet.net
  • Subject: [mg61758] Re: [mg61732] Re: Running the kernel command line with additional input files
  • From: Chris Chiasson <chris.chiasson at gmail.com>
  • Date: Fri, 28 Oct 2005 03:25:43 -0400 (EDT)
  • References: <djhsok$shl$1@smc.vnet.net> <200510270902.FAA19502@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Thank you. That was informative.

On 10/27/05, fiaminamor at gmail.com <fiaminamor at gmail.com> wrote:
> kalymereau at yahoo.fr wrote:
> > Hi MathGroup
> >
> > I have a package myPack.m that reads input from two text files
> > file1.txt file2.txt
> >
> > The names of the files will change from job to job and thus have to be
> > given by the user.
>
>
> Yes, you can read arguments from the command line like you want.
> Here are two useful facts about Mathematica's math.exe kernel.
>
> First, all the command-line arguments are available as a list in the
> Mathematica variable $CommandLine.
>
> Second, Mathematica accepts any command-line argument, even ones that
> it doesn't understand.
>
> These two facts mean that you can supply your own arguments and they'll
> appear in $CommandLine.
>
> C:\Mathematica\5.2> math -argumentstomypackage file1.txt file2.txt
>
> Mathematica 5.2 for Microsoft Windows
> Copyright 1988-2004 Wolfram Research, Inc.
>  -- Terminal graphics initialized --
>
> In[1]:= $CommandLine
>
> Out[1]= {math, -argumentstopackage, file1.txt, file2.txt}
>
> Now you can write a function that finds your -argumentstomypackage flag
> in the $CommandLine list, and then pulls out the next 2 arguments.
>
> To run a Mathematica .m file from the command line, use the -run option
> to math.exe.
>
>   math.exe -run mypackage.m -argumentstomypackage file1.txt file2.txt
>
> Now it is up to you to write the function in "mypackage.m" that pulls
> "file1.txt" and "file2.txt" from the $CommandLine variable.
>
>


--
http://chrischiasson.com/contact/chris_chiasson


  • Prev by Date: A Problem with the NonlinearFit?
  • Next by Date: Re: Re: IMAP interface to Mathematica
  • Previous by thread: Re: Running the kernel command line with additional input files
  • Next by thread: 'Raw Expressions'