Learn R Programming

rpymat (version 0.1.7)

run_command: Execute command with additional environments

Description

Enables 'conda' environment

Usage

cmd_create(command, shell, use_glue = TRUE)

cmd_set_env(command, key, value, quote = TRUE, quote_type = "cmd")

cmd_set_workdir(command, workdir)

cmd_set_conda(command, conda_path, env_path)

cmd_build(command, .env = parent.frame(), ...)

detect_shell(suggest = NULL)

run_command( command, shell = detect_shell(), use_glue = FALSE, enable_conda = TRUE, stdout = "", stderr = "", stdin = "", input = NULL, env_list = list(), wait = TRUE, timeout = 0, ..., workdir = getwd(), dry_run = FALSE, print_cmd = dry_run, glue_env = parent.frame() )

Value

All the functions return a list with class rpymat_system_command except for run_command, which returns the exit code by system2.

Arguments

command

system command

shell

shell type

use_glue

whether to glue the command; default is false

key, value

environment variable key and value

quote, quote_type

whether to quote the environment variables and what quote type should use; see shQuote

workdir

the working directory

conda_path

'conda' path; default is conda_path

env_path

'conda' environment path; default is env_path

suggest

suggested shell type; default is 'cmd' on windows, or 'bash' on others

enable_conda

whether to activate 'conda'

stdout, stderr, stdin, input, wait, timeout, ...

passed to system2

env_list

a key-value pairs of environment variables

dry_run

whether to dry-run the command (do not execute, simply returns the command), useful to debug

print_cmd

whether to print the command out

glue_env, .env

the environment to evaluate variables when use_glue is true

Examples

Run this code

run_command("conda install -y numpy", dry_run = TRUE)


a <- "This is a message"
run_command('echo "{a}"', dry_run = TRUE,
            enable_conda = FALSE, use_glue = TRUE)


if (FALSE) {

# Use `jupyter_launch()` instead. This is just a demonstration
run_command('"{jupyter_bin()}" server list', use_glue = TRUE)

}

Run the code above in your browser using DataLab