2
$\begingroup$

From Run's documentation

 commandstring = First[$CommandLine] <> " -noprompt -run \"Put[Factorial[20],ToFileName[$TemporaryDirectory,ToString[temp1]]];Quit[]\""

(* "WolframKernel -noprompt -run "Put[Factorial[20],ToFileName[$TemporaryDirectory,ToString[temp1]]];Quit[]" *)

It is then claimed that this command exits without error

 Run[commandstring]

 (* 0 *)

but instead of the documented output - 2432902008176640000, no file seems to have been Put?

 FilePrint[ToFileName[$TemporaryDirectory, ToString[temp1]]]

 (* General::noopen: Cannot open /var/folders/1k/xb6km42x5fg7bv3g2hdnjft40000gn/T/temp1. >> *)

[Observed on Mma V 10.2 , OS X 10.10.5]

$\endgroup$
0

1 Answer 1

8
$\begingroup$

This is a documentation bug that has been fixed recently.

The following properly escaped for running in a shell version of the example should work on OS X,

commandstring = First[$CommandLine] <> 
  " -noprompt -run \"Put[Factorial[20], FileNameJoin[{\$TemporaryDirectory, \\\"temp1\\\"}]
]; Quit[]\""

Run[commandstring]

(* 0 *)

FilePrint[FileNameJoin[{$TemporaryDirectory, "temp1"}]]

(* 2432902008176640000 *)
$\endgroup$
1
  • 1
    $\begingroup$ Ok, thanks, I could have I suppose, spotted that escaping on a shell first but still - am mildly curious as to whether or not documentation inputs are included in regression testing ... $\endgroup$ Sep 9, 2015 at 4:48

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.