Sys.which {base}R Documentation

Find Full Paths to Executables

Description

This is an interface to the system command which.

Usage

Sys.which(names)

Arguments

names Character vector of names of possible executables.

Details

The system command which reports on the full names of an executable (including an executable script) found on the current path.

On Windows an ‘executable’ is a file with extension ‘.exe’, ‘.com’, ‘.cmd’ or ‘.bat’. Such files need not actually be executable, but they are what system tries.

On a Unix-alike the full path to which (usually ‘/usr/bin/which’) is found when R is installed and (currently) stored in environment variable WHICH.

Value

A character vector of the same length as names, named by names. The elements are either the full path to the executable or some indication that no executable of that name was found. Typically the indication is "", but this does depend on the OS (and the known exceptions are changed to "" as from R 2.12.0).

Examples

## the first two are likely to exist everywhere
## texi2dvi exists on most Unix-alikes and under MiKTeX
Sys.which(c("ftp", "ping", "texi2dvi", "this-does-not-exist"))

[Package base version 2.12.0 Index]