Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

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

Search the Archive

Re: Running MathematicaScript in Mac Terminal

  • To: mathgroup at smc.vnet.net
  • Subject: [mg124981] Re: Running MathematicaScript in Mac Terminal
  • From: Murray Eisenberg <murray at math.umass.edu>
  • Date: Wed, 15 Feb 2012 04:45:15 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201202141140.GAA17797@smc.vnet.net>
  • Reply-to: murray at math.umass.edu

For Mathematica 8.0.4 under Mac OS X, the location of MathematicaScript is:

   /Applications/Math/Mathematica.app/Contents/MacOS/MathematicaScript

I saved your script as ~/Desktop/script.txt, with that change:

-------------------------------------------------------------------------
#!/Applications/Mathematica.app/Contents/MacOS/MathematicaScript -script

Print /@ RandomVariate[MixtureDistribution[
     {1,2},
     {NormalDistribution[1,2/10],
      NormalDistribution[3,1/10]}],
     10,  WorkingPrecision -> 50]
-------------------------------------------------------------------------

 From the Terminal command line, I executed:

/Applications/Mathematica.app/Contents/MacOS/MathematicaScript -script 
~/Desktop/script.txt

(all on one line).

I get back a bunch of error messages

   FrontEndObject::notavail: A front end is not available; certain
   operations require a front end.

... along with a bunch of numbers.

I evaluated the same expression in a Mathematica front end, noticing 
that those numbers appear followed by a list of Nul entries. So I tried 
the same thing again as a script, this time without the "Print /@" part, 
which I think is superfluous in any case. The result -- error messages 
and numbers -- is essentially the same.

I'm not familiar with the statistical functions in Mathematica to 
understand yet what a front end has to do with this.


On 2/14/12 6:40 AM, Murta wrote:
> Hi All
> I use Mathematica 8 Home edition and I'm testing running Script via
> Shell in my MacOS.
> I followed the tutorial, changed the permission using chmod a+x
> script.m but it doesn't worked.
>
> the script is this (copy and paste the tutorial)
>
> ------------------------------------------------
> #!/usr/local/bin/MathematicaScript -script
>
> Print /@ RandomVariate[MixtureDistribution[
>      {1,2},
>      {NormalDistribution[1,2/10],
>       NormalDistribution[3,1/10]}],
>      10,  WorkingPrecision ->  50]
> ------------------------------------------------
> I didn't find the MathematicaScript file that the tutorial says it's
> in #!/usr/local/bin/MathematicaScript
> maybe it could be de problem.
>
> my directory has:
>
> /usr/local/bin>ls
> capinfos  dvipdf    flac      mergecap  pgpdisk   pkill.pl  text2pcap
> twfind
> dftest    edit      idl2wrs   metaflac  pgpwde    randpkt   tshark
> wget
> dumpcap   editcap   latex     pdf2ps    pgrep.pl  rawshark  twdiff
> wireshark
>
> What I'm doing wrong?
> tks in advance!
> Murta
>

-- 
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305



  • Prev by Date: NETLink on 64-bit Windows
  • Next by Date: Re: surprising timings for multiplication of diagonalmatrix and full matrix
  • Previous by thread: Re: Running MathematicaScript in Mac Terminal
  • Next by thread: Re: Running MathematicaScript in Mac Terminal