How to use execve to export environment variables
source link: https://www.codesd.com/item/how-to-use-execve-to-export-environment-variables.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
How to use execve to export environment variables
I am trying to figure out how to export this environmental variables from my minishell to bash. Nothing happens when I use this code to export. Am I doing something wrong
if(strcmp(istring, "myexport") ==0) //This command shows parent enviornment
{
char * const *junk;
execve("/bin/bash" , junk , myexp);
return(1);
}
char *const argv = { "-c", "env", 0 };
char *const env = { "PATH=/bin", "USER=wibble", 0 };
execve("/bin/bash", argv, env);
And of course you can fetch things our of the existing environment by using extern char **environ;
or getenv
to construct the environment for the new binary/script.
Related Articles
How to use setenv () to export a variable in c ++?
How to use the docker-compose environment variables to populate the configuration file
How to use the Travis CI environment variables + .sh script for automatic deployment on Github Pages?
How do I set a global environment variable from the Inno Setup installer?
Should I use user-secrets or environment variables with docker
How do I get the system environment variables using the boost library?
How do I use the Computer Name environment variable in VBS with MsgBox?
How to get the value of environment variables?
How do I replace the http_proxy environment variable in Jenkins?
How do I enable NODE_DEBUG without environment variables?
How do I include the maven environment variables in the eclipse to war file
How do I know if an environment variable has been inherited from the parent process?
How to avoid overloading the PATH environment variable in Windows?
How to programmatically set a permanent environment variable in Linux?
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK