2

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]

Ronald Monson
  • 6,076
  • 26
  • 46

1 Answers1

8

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 *)
ilian
  • 25,474
  • 4
  • 117
  • 186
  • 1
    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 ... – Ronald Monson Sep 09 '15 at 04:48