>From a batch file, you can redirect the output using ">" . See http://blog.crankybit.com/redirecting-output-to-a-file-in-windows-batch-scripts/ for some details.
Alternatively, if you control how the output is generated, you can use the Logging.jl package to write them to file in reasonably flexible way. Regards - Avik On Tuesday, 23 June 2015 07:55:54 UTC+1, bernhard wrote: > > Hi all > > I am invoking a Julia process from an external program (say a Java script, > Windows or any program). > Julia starts, does some calculations and closes again. While Julia runs I > can of course see the REPL which shows me some logging and evaluations. > > I now want to set up a web service (REST or similar) where people can > upload data, start of a model, and download results. For this I want to > have a log file which shows the same or similar output which the REPL > (=Julia session) displays. I understand that the REPL is does much more > than just displaying stdout and stderr (this is why is said similar before). > > Leah Hanson is describing > <http://blog.leahhanson.us/running-shell-commands-from-julia.html> (Base.|> > ) which works perfectly for me. But this only works if I use Julia to > start another Julia session. In my case I want to start Julia from windows > (a *.bat file) or any other software. How can I achieve the same result? > > I am aware of redirect_stdout and redirect_stderr. This does not work > properly for me, as the program might run for several minutes, and it seems > to me that output is only written after I flush or close the stream. But I > want to see the progress in the log file (just as the REPL does) while my > code runs. It would be tedious to add "flush" everywhere in my code where > I have a print command. > > Is there a way to achieve this? > > As mentioned above I can invoke a julia session which starts another julia > session with the actual code: > (st,pr) = open(`$(juliaExecutable) $(juliaProgram) $(arguments)` |> > logFilename) > Is there a way to achieve the same result without the intermediate julia > session? > > Thanks > Bernhard >
