Skip to content

Instantly share code, notes, and snippets.

@grayskripko
Last active March 17, 2017 10:01
Show Gist options
  • Save grayskripko/f324062f127d0cf22bccf707d2299b26 to your computer and use it in GitHub Desktop.
Save grayskripko/f324062f127d0cf22bccf707d2299b26 to your computer and use it in GitHub Desktop.
> winCmd <- 'R -q -e "11+1; 1+undef_var; 12+2"'
> pp <- pipe(winCmd, open='r')
> readLines(pp) # does not return any error message and freezes
[1] "> 11+1; 1+undef_var; 12+2" "[1] 12"
> close(pp)
> winCmd <- 'R -q -e "11+1; 1+undef_var; 12+2" 2>&1'
> pp <- pipe(winCmd, open='r')
> readLines(pp) # works fine
[1] "> 11+1; 1+undef_var; 12+2" "[1] 12"
[3] "Error: object 'undef_var' not found" "Execution halted"
> close(pp)
# the reason is pipe does not read stderr stream
# https://blogs.msdn.microsoft.com/ejarvi/2005/01/28/redirecting-stderr-to-stdout-on-the-command-line/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment