Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 54495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:13:44+00:00 2026-05-10T17:13:44+00:00

If you have Mathematica code in foo.m, Mathematica can be invoked with -noprompt and

  • 0

If you have Mathematica code in foo.m, Mathematica can be invoked with -noprompt and with -initfile foo.m (or -run '<<foo.m') and the command line arguments are available in $CommandLine (with extra junk in there) but is there a way to just have some mathematica code like

#!/usr/bin/env MathKernel x = 2+2; Print[x]; Print['There were ', Length[ARGV], ' args passed in on the command line.']; linesFromStdin = readList[]; etc. 

and chmod it executable and run it? In other words, how does one use Mathematica like any other scripting language (Perl, Python, Ruby, etc)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T17:13:45+00:00Added an answer on May 10, 2026 at 5:13 pm

    MASH — Mathematica Scripting Hack — will do this.

    Since Mathematica version 6, the following perl script suffices:

    http://ai.eecs.umich.edu/people/dreeves/mash/mash.pl

    For previous Mathematica versions, a C program is needed:

    http://ai.eecs.umich.edu/people/dreeves/mash/pre6

    UPDATE: At long last, Mathematica 8 supports this natively with the ‘-script’ command-line option:

    http://www.wolfram.com/mathematica/new-in-8/mathematica-shell-scripts/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried the mathematica code for making the chaos game for DNA sequences
Can anybody recommend a pattern for unit-testing code within a Mathematica notebook ? I
I have this code in Mathematica: nxBin = Table[{-5 sX + (i - 0.5)*step,
I have the following code from mathematica and trying to do it with matlab
I have a Mathematica code where I have to evaluate numerically thousands of integrals
Run the following code In Mathematica: r=6197/3122; p[k_,w_]:=Sqrt[w^2/r^2-k^2];q[k_,w_]:=Sqrt[w^2-k^2]; a[k_,w_,p_,q_]:=(k^2-q^2)^2 Sin[p]Cos[q]+4k^2 p q Cos[p]Sin[q] a[k_,w_]:=a[k,w,p[k,w],q[k,w]];
I have mathematica code to check whether a collection of sets satisfies the definition
In Mathematica I have a list: x = {1,2,3,3,4,5,5,6} How will I make a
I have a 15-day trial of Mathematica and need to evaluate it, and see
I have code similar to: if conditionA(x, y, z) then doA() else if conditionB(x,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.