Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: print output from R to windows console #93

Open
MoREpro opened this issue Jul 21, 2022 · 7 comments
Open

Feature Request: print output from R to windows console #93

MoREpro opened this issue Jul 21, 2022 · 7 comments

Comments

@MoREpro
Copy link

MoREpro commented Jul 21, 2022

We use the package on our server for several tasks and this is working great.
The only downside is, that several black console windows are shown, but it is not possible to see, if something is done successfully in the background or a problem has occured or even if this console is caused by the task created with rtaskscheduler.
Is it possible to implement a feature, that output from R is shown in the windows console during execution?
That would be wonderfull.

@jwijffels
Copy link
Collaborator

If I correctly understood, this is the same question/remark as #87 (comment)

@MoREpro
Copy link
Author

MoREpro commented Jul 22, 2022

No, it is not the same question: I can see results of the tasks in the logfiles, but only if I know which task is writing the logfiles where and then go there and open the file.
Me request is about showing the output of R in real time in the console which is open during processing. If a colleague has setup a R-task on the server, and I do not know about it, when I access the server I only see a emty console window without any information which programm caused this window and if something is still ongoing. I would like to see some output (messages, warnings) from R there, to know what is done and if the processing is going on sccessfully. I can create all these output in R but I do not know how to pipe it into the console window.

@jwijffels
Copy link
Collaborator

I meant that the solution is the same as what is depicted at #87 (comment)

@MoREpro
Copy link
Author

MoREpro commented Jul 25, 2022

I might be able to change the location where to write the log-files. But how does this bring them to the console output? Is the console window I see from R or from the windows task scheduler? If it is the R console, why are the messages not shown by default, as it is when I run the srcipt from the GUI?
I have some medium knowledge in R, but I'm not very experienced with Windows scripting and so on. Maybe you can give me a more detailed description, how to approach this problem?

@jwijffels
Copy link
Collaborator

jwijffels commented Jul 25, 2022

Code

task <- sprintf("cmd /c %s %s %s >> %s 2>&1", Rexe, shQuote(rscript), paste(rscript_args, collapse = " "), shQuote(sprintf("%s.log", tools::file_path_sans_ext(rscript))))
is where the piping occurs.
>> means append it to the log file
2>&1 means put all printed statements and errors and warnings in that log file, if you omit it, it just prints normal print statements to the console which is popped up instead of sending it to the log file.
If you want to see progress, add options(echo = TRUE) in your R code.
If you just want to see which processes are running, call taskscheduler_ls
If your question is more like 'I'm using RStudio as a GUI and I'm expecting the progress to be printed there', I have to inform you that this R package has nothing to do with RStudio.

@MoREpro
Copy link
Author

MoREpro commented Jul 29, 2022

What you pointed out about the piping is exactly what I'was looking for. But I would need to print the output to the console and write it to the log file. Is that possible as well?

@jwijffels
Copy link
Collaborator

You can look at the code at the cronR package, there this is implemented https://github.com/bnosac/cronR/blob/master/R/cron_rscript.R#L36-L113

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants