[R] How to check if a pipe was successfully opened or not?
Henrik Bengtsson
hb at maths.lth.se
Fri May 30 16:40:23 CEST 2003
Is there a way to detect if the opening of a connection to a pipe was
successful or not? Here are two examples
# Works
> con <- pipe("ls")
> res <- open(con, open="r")
> print(res)
NULL
# Does not work
> con <- pipe("unknown_command")
> res <- open(con, open="r")
> 'unknown_command' is not recognized as an internal or external
command,
operable program or batch file.
> print(res)
NULL
Can I make my script recognize/detect that the latter failed? try() will
not catch the error. The error message is not written to stdout so
sink() won't "catch" it either. Does anyone know of a (cross-platform)
way to test if "unknown_command" exists or not on the current system
before calling pipe()/open()?
I'm running R v1.7.0 on WinXP.
Thanks
Henrik Bengtsson
Dept. of Mathematical Statistics @ Centre for Mathematical Sciences
Lund Institute of Technology/Lund University, Sweden
(Sweden +2h UTC, Melbourne +10 UTC, Calif. -7h UTC)
+46 708 909208 (cell), +46 46 320 820 (home),
+1 (508) 464 6644 (global fax),
+46 46 2229611 (off), +46 46 2224623 (dept. fax)
h b @ m a t h s . l t h . s e, http://www.maths.lth.se/~hb/
More information about the R-help
mailing list