Colleagues, I am writing scripts that run on both Windows (Vista) and Linux (RedHat 9). The scripts will be used in both S-Plus (version 8) and R (2.6.0). I am trying to use the "status" portion of the quit command: ------------------------------------------------------------------------ ----------------------------------------------------------------------- > quit package:base R Documentation > > Terminate an R Session > > Description: > > The function 'quit' or its alias 'q' terminate the current R > session. > > Usage: > > quit(save = "default", status = 0, runLast = TRUE) > q(save = "default", status = 0, runLast = TRUE) > .Last <- function(x) { ...... } > > Arguments: > > save: a character string indicating whether the environment > (workspace) should be saved, one of '"no"', '"yes"', '"ask"' > or '"default"'. > > status: the (numerical) error status to be returned to the operating > system, where relevant. Conventionally '0' indicates > successful completion. > > > > > Some error statuses are used by R itself. The default error > handler for non-interactive use effectively calls 'q("no", 1, > FALSE)' and returns error code 1. Error status 2 is used for R > 'suicide', that is a catastrophic failure, and other small > numbers > are used by specific ports for initialization failures. It is > recommended that users choose statuses of 10 or more. > > Valid values of 'status' are system-dependent, but '0:255' are > normally valid. ------------------------------------------------------------------------ ----------------------------------------------------------------------- Of the four combinations (R/S-Plus crossed with Windows/Linux), the only combination that I cannot get to work properly is R/Windows.
The code below from Linux/R: > > q(status=34, "no") > P2: 72> echo $status > 34 shows the expected response. When I replicate that R code in Windows, then type: 1. echo %status%: Windows echoes %status, indicating that the environment variable status was never set 2. echo %error level%: Windows echoes 1 (if i execute a normal quit command, i.e., without setting status, Windows echoes 0). So, it appears that in Windows, %errorlevel% is the (undocumented) equivalent of $status (Linux). However, in Windows, the value returned appears to be limited to either 0 (normal exit) or 1 (status set to a non-zero value) despite the claim that "valid values ... [are] 0:255 (as is the case in Linux). Does any one have an experience with this? I realize that another option is to write "status" to a (hidden) file, then read it from the OS. However, there are reasons why this is not desirable. Dennis Dennis Fisher MD P < (The "P Less Than" Company) Phone: 1-866-PLessThan (1-866-753-7784) Fax: 1-415-564-2220 www.PLessThan.com [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.