How to access OS environment variable from shiny app's server.R

Hi Jasmin, I was trying to recreate your request and it should work based on your mentioned code-snippet. :wink:

Best regards
Adam

P.S. Below is a short example: :slight_smile:

library(shiny)

ui <- fluidPage(
  #display your 'textoutput'
  textOutput("textoutput")
)

server <- function(input, output, session){
  #get your user name based on 'Sys.getenv' (static object)
  user.name <- paste0("user name is ",Sys.getenv(c("USER")))
  #test user.name easy by printing on console
  print(user.name)
  
  #create UI output object 
  output$textoutput <- renderText({
    user.name
  })
}

shinyApp(ui, server)

1 Like