I want to run an R script on a remote server that depends on a MySQL connection that requires VPN. I do this on my local machine using a Cisco VPN client.
Is there any way to facilitate a MySQL connection for an R application where VPN is required?
More specifically, I'm interested in facilitating either a knitr script to produce html on the remote server or to deploy my shiny app on the remote server, but for both I would need the MySQL queries to run against a server via VPN. Any thoughts on this process or work-arounds would be greatly appreciated.
Thanks for your help.
自询问以来已经过去了,但我找到了解决此问题或类似问题的方法。要连接到我的数据库,我需要通过 VPN 来完成,但我不需要 24/7 连接。
cmd <- unname(Sys.which("rasdial"))
cmd_args <- c('"VPN NAME"', userID, pass)
system2(command = cmd, args= cmd_args)
con <- dbConnect(odbc::odbc(), ... )
# Do your stuff
# Close the connection
cmd_args <- c('"VPN NAME"', '/DISCONNECT')
system2(command = cmd, args= cmd_args)
Run Code Online (Sandbox Code Playgroud)
这样我就可以在任务计划程序中自动执行脚本