I am running R on EC2 spot instances and I need R to terminate the instance and cancel the spot request once the script has run.
For that I have set the \"Request ID
You want Sys.getenv() as in Sys.getenv("PATH"), say.
Sys.getenv()
Sys.getenv("PATH")
Or for your example, try
SIR <- Sys.getenv("SIR") system(paste("ec2-cancel-spot-instance-requests", SIR))
As for setting variables at startup, see help(Startup) to learn about ~/.Renvironment etc
help(Startup)
~/.Renvironment