scriptexec v0.3.1
0
Monthly downloads
Execute Native Scripts
Run complex native scripts with a single command, similar to system commands.
Readme
scriptexec
Run complex native scripts with a single command, similar to system commands.
Overview
The purpose of the scriptexec package is to enable quick and easy way to execute native scripts.
Usage
Simply load the library and invoke the execute
library(scriptexec)
# execute script text
output <- scriptexec::execute("echo command1\necho command2")
expect_equal(output$status, 0)
expect_equal(grepl("command1", output$output), TRUE)
expect_equal(grepl("command2", output$output), TRUE)
if (.Platform$OS.type == "windows") {
ls_command <- "dir"
} else {
ls_command <- "ls"
}
output <- scriptexec::execute(c("echo user home:", ls_command))
expect_equal(output$status, 0)
# execute multiple commands as a script
output <- scriptexec::execute(c("cd", "echo test"))
expect_equal(output$status, 0)
# pass arguments (later defined as ARG1, ARG2, ...) and env vars
if (.Platform$OS.type == "windows") {
command <- "echo %ARG1% %ARG2% %MYENV%"
} else {
command <- "echo $ARG1 $ARG2 $MYENV"
}
output <- scriptexec::execute(command, args = c("TEST1", "TEST2"), env = c("MYENV=TEST3"))
expect_equal(output$status, 0)
expect_equal(grepl("TEST1 TEST2 TEST3", output$output), TRUE)
# non zero status code is returned in case of errors
expect_warning(output <- scriptexec::execute("exit 1"))
expect_equal(output$status, 1)
# do not wait for command to finish
output <- scriptexec::execute("echo my really long task", wait = FALSE)
expect_equal(output$status, -1)
Installation
Install from CRAN:
install.packages("scriptexec")
Install latest release from github:
devtools::install_github("sagiegurari/scriptexec@0.3.1")
Install current development version from github (might be unstable):
devtools::install_github("sagiegurari/scriptexec")
API Documentation
See full docs at: API Docs
Contributing
Release History
See NEWS
License
Developed by Sagie Gur-Ari and licensed under the Apache 2 open source license.
Functions in scriptexec
| Name | Description | |
| generate_env_setup_script | Generates and returns a script which sets up the env vars for the script execution. | |
| build_output | Builds the output structure. | |
| generate_args_setup_script | Generates and returns a script which sets up the env vars for the script arguments | |
| scriptexec | scriptexec: Execute native scripts | |
| create_script_file | Creates a temporary file, writes the provided script content into it and returns the file name. | |
| get_platform_value | Returns the value based on the current platform. | |
| get_command | Returns the command and arguments needed to execute the provided script file on the current platform. | |
| on_invoke_error | Internal error handler. | |
| modify_script | Modifies the provided script text and ensures the script content is executed in the correct location. | |
| create_system_call_args | Returns the system call arguments. | |
| execute | Executes a script and returns the output. The stdout and stderr are captured and returned. In case of errors, the exit code will return in the status field. | |
| is_windows | Returns true if windows, else false. | |
| No Results! | ||
Vignettes of scriptexec
| Name | ||
| scriptexec.Rmd | ||
| No Results! | ||
Last month downloads
Details
| License | Apache License 2.0 |
| URL | https://github.com/sagiegurari/scriptexec |
| BugReports | https://github.com/sagiegurari/scriptexec/issues |
| Encoding | UTF-8 |
| RoxygenNote | 6.1.1 |
| VignetteBuilder | knitr |
| NeedsCompilation | no |
| Packaged | 2019-04-12 17:02:15 UTC; pi |
| Repository | CRAN |
| Date/Publication | 2019-04-12 17:22:38 UTC |
| suggests | devtools (>= 2.0.2) , formatR (>= 1.6) , knitr (>= 1.22) , lintr (>= 1.0.3) , Rd2md (>= 0.0.2) , rmarkdown (>= 1.12) , roxygen2 (>= 6.1.1) , testthat (>= 2.0.1) |
| depends | R (>= 3.2.3) |
| Contributors |
Include our badge in your README
[](http://www.rdocumentation.org/packages/scriptexec)