Code: Select all
(load "../newlisp_armory/codes/env/env.lsp")
(envex:load-env-tool)
(envex:set-sys-env "CLOUD_ENGINE_HOME" cloud-engine-home)
the load-env-tool function defined in env.lsp will get the os type and then load env_ubuntu.lsp because I am in Ubuntu. Below is the codes of env.lsp.
Code: Select all
;; env.lsp
(context 'envex)
;; an exception will be thrown out if the OS is neither Linux nor Windows
;; note: only Ubuntu and Windows 7 are supported for now
(define (load-env-tool)
(if
(= ostype "Linux") (load "env_ubuntu.lsp")
(= ostype "Win32") (load "env_win.lsp")
(throw-error (append "env tool doesn't support this OS for now, ostype:" ostype))
))
Code: Select all
;; env_ubuntu.lsp
(context 'envex)
;; save the environment variable into /etc/environment
;; need root permission
;; also export the environment for subsequently executed commands
(define (set-sys-env str-name str-value)
(env str-name str-value)
(unless (regex str-name (read-file "/etc/environment"))
(unless (append-file "/etc/environment" (append "\n" str-name "=\"" str-value "\"\n"))
(throw-error (append "write /etc/environment failed, error:" (string (sys-error)))))
)
)
Code: Select all
./setup.lsp
ERR: problem accessing file in function load : "env_ubuntu.lsp"
called from user defined function envex:load-env-tool