4
$\begingroup$

I just installed v11, and I wanted to try wolframscript at the console.

Whatever I try, it works, but always adding at the beginning the annoying warning

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

which it adds even for a simple wolframscript -code 2+2

There is a way to avoid it?

$\endgroup$
7
  • $\begingroup$ Are you running it on a headless machine? $\endgroup$
    – Szabolcs
    Commented Aug 17, 2016 at 7:53
  • $\begingroup$ no, it's a desktop - but I like to use the console whenever I can $\endgroup$
    – alessandro
    Commented Aug 17, 2016 at 8:42
  • $\begingroup$ So just to make it clear, you do have an X server running, right? $\endgroup$
    – Szabolcs
    Commented Aug 17, 2016 at 8:46
  • $\begingroup$ :-) yes, I have it - and the M frontend works perfectly on it... (it is a Fedora fc20) $\endgroup$
    – alessandro
    Commented Aug 17, 2016 at 9:14
  • $\begingroup$ I don't have M11 on Linux now to confirm, but it sounds like something worth reporting to Wolfram Support. $\endgroup$
    – Szabolcs
    Commented Aug 17, 2016 at 9:15

1 Answer 1

1
$\begingroup$

The answer from Wolfram was that they were unable to replicate my bug - but they just tried it with Ubuntu. From what I see by b.gatessucks, whatever issue it is, it must be present at least in Fedora fc20...

Anyway - just to show myself that I could do it, and just for fun - I put this code in my .bashrc (it needs ImageMagick):

wcalc(){
        echo -n -e "Input/Output loop with Mathematica syntax\npre-pend \"g\" to have graphics output (if ImageMagick installed)\nCtrl-C to exit\nw> "
        perl -wne'chomp;(substr($_, 0, 1) eq "g") ?
        do{$x="g";$_=~s/^.//;$a=`wolframscript -code "$_"  -format PNG >file.png 2>/dev/null`}:
        do{$x="";$a=`wolframscript -code $_ 2>&1`};
        $x eq "" ? do{@b=split(/\n/,$a);print"$b[2]\nw> "}:
        do{print"\nw> ";system("display file.png 2>/dev/null&")}';
        }
export -f wcalc

With it, the command wcalc starts a quick Mathematica session at the console. The same as calling math at the console, but with the added benefits that

1) I was able to use wolframscript as I wanted (I get rid of the warning I asked about, by splitting @b and printing just $b[2]), and

2) if you pre-prend your command by "g", e.g.

w> gPlot[Sin[x],{x,0.,5}]

it is able to open the graphics (using display by ImageMagick) .

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.