Friday, August 1, 2014

Add Environment Variables in C++ Code

char *shell;


/* Get the path of the current shell to start it later */
shell = getenv("SHELL");
if (shell == NULL) {
    fprintf(stderr, "Error eding SHELL env. var.\n");
    return 1;
}       

/* Overwrite env. var. PATH */
if (setenv("PATH", "/usr/bin", 1) < 0) {
    fprintf(stderr, "Error setting env. var.\n");
    return 1;
}
Check also: http://linuxconfig.org/set-and-get-environmental-shell-variable-using-c 

No comments:

Post a Comment

Setting Jupyter and Tensorflow on Google Cloud Platform

https://towardsdatascience.com/running-jupyter-notebook-in-google-cloud-platform-in-15-min-61e16da34d52