Reputation: 3524
I have a shiny app which needs to run system commands to trigger a data integration job through a call to system(), if i run stand-alone shiny(running with runApp) this works fine, however if i deploy the code to shiny-server without changes the system() command do not work . Is system() a valid call inside shiny server? If not, what alternatives are there to execute system commands ?
Upvotes: 0
Views: 1301
Reputation: 3524
In case anyone get in this situation ,i found my problem was because shiny-server runs under "shiny" user which did not have privileges to run the system command i needed(run some scripts) and also did not have privileges(read nor execute) to the scripts, it was fixed by granting the necesary rights to the "shiny" user.
Upvotes: 0
Reputation: 33510
Running system()
in shiny (& shiny-server) works just fine:
library(shiny)
ui <- fluidPage(
textOutput("dirOut")
)
server <- function(input, output) {
SysName <- Sys.info()['sysname']
if(SysName=="Linux"){
dir <- system("pwd", intern = TRUE)
} else if(SysName=="Windows"){
dir <- system("cmd cd", intern = TRUE)
} else {
dir <- paste("Error: No cmd given for", SysName)
}
output$dirOut <- renderText({
dir
})
}
shinyApp(ui = ui, server = server)
Upvotes: 2