I am looking for a way to passing arguments into a WL script when WL run in batch modes. The test script is:
#!/usr/bin/env wolframscript
(*generate "num" samples of a mixed distribution*)
num = ToExpression[$ScriptCommandLine];
Print["num ", num];
Print /@ RandomVariate[
MixtureDistribution[{1, 2}, {NormalDistribution[1, 0.2],
NormalDistribution[3, 0.1]}], num, WorkingPrecision -> 50]
The output file:
Mathematica 11.3.0 Kernel for Linux x86 (64-bit)
Copyright 1988-2018 Wolfram Research, Inc.
In[1]:=
In[2]:= num {}
In[3]:=
Out[3]= True
Out[4]= 1.2216923087229409686348818698669268506575506911553
And the sh
script :
#!/bin/sh
#$ -cwd
/gpfs0/system/Mathematica/11.3/Executables/math < test.wls 3 > test_out.txt
It is looks that I do not succeed to pass the arguments to the script. Any suggestion on how to do it correctly?