I'm using Mathematica Home Edition 9.0.1 on Mac OS X 10.8.2.
I have this script:
#!/Applications/Mathematica.app/Contents/MacOS/MathematicaScript -script
exportableDate[date_] := 10000 date[[1]] + 100 date[[2]] + date[[3]];
dividendTable = FinancialData[$ScriptCommandLine[[2]], "Dividend", All];
exportableDividendTable = { exportableDate[#[[1]]], #[[2]] }& /@ dividendTable;
Export[$Output, exportableDividendTable, "CSV"];
When I run it without redirecting stdout
, it works:
$ ./dividendsForSymbol INTC
StringForm["Initializing `1` indices ....", "FinancialData"]
19921026,0.00313
19930126,0.00313
19930426,0.00313
19930726,0.00313
19931026,0.00313
19940126,0.00313
...
When I redirect the output to a file, it just exits immediately without producing any output:
$ ./dividendsForSymbol INTC > out
$ echo $?
0
$ ls -l out
-rw-r--r-- 1 mayoff staff 0 Mar 9 17:18 out
Why is it failing when I redirect the output? Or, how can I diagnose the problem?
#!/Applications/Mathematica.app/Contents/MacOS/MathematicaScript -script Export[$Output, 3, "CSV"];
$\endgroup$