1

I am looking for a way to capture standard error and redirect it to standard output in R (Shiny). I can not find any information any where in the web. Is there a way to do this?

closed as off-topic by N0rbert, muru, waltinator, Eliah Kagan, Zanna Apr 12 '18 at 21:21

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This is not about Ubuntu. Questions about other Linux distributions can be asked on Unix & Linux, those about Windows on Super User, those about Apple products on Ask Different and generic programming questions on Stack Overflow." – N0rbert, muru, waltinator, Zanna
If this question can be reworded to fit the rules in the help center, please edit the question.

  • I am trying the code below so that if there is neither "/" nor "\" the output is an error and the application stops, but ir does not work. if(!grepl("/", OUTpath, fixed=TRUE) || !grepl("\\", OUTpath, fixed=TRUE)){ trueFalse = FALSE errorMessage("Unrecognized path separator in OUTpath or no path specification in PARAMS file. Cannot open connection\n You can edit your input file and save the changes. Afterwards, stop and restart glycoPipe and upload file again") stop("Unrecognized path separator in OUTpath\n") } – gccd Apr 11 '18 at 20:00
  • I am trying the code below so that if there is neither "/" nor "\" the output is an error and the application stops, but ir does not work. if(!grepl("/", OUTpath, fixed=TRUE) || !grepl("\\", OUTpath, fixed=TRUE)){ trueFalse = FALSE errorMessage("Unrecognized path separator in OUTpath or no path specification in PARAMS file. Cannot open connection\n You can edit your input file and save the changes. Afterwards, stop and restart glycoPipe and upload file again") stop("Unrecognized path separator in OUTpath\n") } – gccd Apr 11 '18 at 20:02
  • Please use the edit link to fix your question. Using the comments for fixing your question is extremely hard to read. The comments are mainly for users to ask for clarification, of which you would normally edit and make yout question clearer based on comments from others. – L. D. James Apr 11 '18 at 20:09
0

This code works. trueFalse and errorMessage are captured by the server by calling the function that produces that code and displayed by using renderText() in the server and textOutput() in the GUI

trueFalse = FALSE
       # capture all the output to a file.
        FILE <- file("log.txt", open = "wt")
        sink(FILE)
        sink(FILE, type = "message")
        #try(log("a"))
        try(message("Path does not exist. You can make changes to the PARAMS file.  Afterwards, stop and restart glycoPipe"))
        ## revert output back to the console -- only then access the file!
        sink(type = "message")
        sink()
        #file.show("log.txt")
        errorMessage <- (readLines("log.txt"))

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