I have a physics simulation program which I run through a terminal window (I use a Mac) as shown below:
user$ programName inputfile.ele
I would like run a *.sh
script that runs the simulation from Mathematica. I tried using Run
but had no luck, though I was able to successfully follow through this example (How to run a shell script from inside Mathematica).
I am looking for advice on how to go about running the simulation from Mathematica. Ultimately, I would like to create a Do-loop and have Mathematica run the following script with different t2 values:
Do[
Clear[t2]
t2 = i;
t2scan = Table[t2, {71}];
t3scan = Range[0.01, 0.08, 0.001];
t2plus3 = t2scan + t3scan;
ans =
Table[
NSolve[{SimpleEquation1 == 0, SimpleEquation2 == 0.03} /. t3 -> angle,
{f, g}], {angle, t3scan}];
fdrift = Flatten[f /. ans];
gdrift = Flatten[g /. ans];
Export["/Users/Desktop/t2.txt", t2scan];
Export["/Users/t3.txt", t3scan];
Export["/Users/t2plus3.txt", t2plus3];
Export["/Users/f.txt", fdrift];
Export["/Users/g.txt", gdrift];
Run["sh myScript.sh"]
, {i, 0.01, 0.08, 0.001}]
Any help would be greatly appreciated.
Run
command, 0 or some other number? $\endgroup$myScript.sh
in the same directory that Mathematica is running from? If you typeDirectory[]
you see what MMA's working directory is. If you go to a terminal and cd into that directory and type yoursh
command, does it work from there? $\endgroup$