12

Is it possible to determine - from within the script - whether the script is running in the R-GUI (specifically R.app on OS X) or whether it has been called from Terminal/command line (i.e. R --vanilla -f script.R)? If so, how is this possible?

I'm asking because I have a script that can run parallelized (using the doMC library), which should not be used from the GUI. Sometimes I need to further process the data calculated in the script, so I'd like to call the script from the GUI on these occasions.

Pascal
  • 16,846
  • 4
  • 60
  • 69

2 Answers2

14

Perhaps you are looking for interactive()?

Aniko
  • 18,516
  • 4
  • 48
  • 45
2

In C, you would use the isatty function. If you could find an equivalent function in R (probably in a UNIX or file system library), that should help.

eduffy
  • 39,140
  • 13
  • 95
  • 92
  • Thanks for the input. I can't find an R-equivalent to `isatty`, also there's nothing in the help pages matching *tty*, but this way surely would be neat. – Pascal Jan 07 '10 at 14:21