The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
environment variables radhika03 Shell Programming and Scripting 3 01-22-2007 01:58 PM
help..Environment variables... sekar sundaram UNIX for Dummies Questions & Answers 3 08-30-2005 03:35 AM
environment variables spavlov UNIX for Dummies Questions & Answers 3 08-20-2003 09:49 AM
environment variables Esaia High Level Programming 2 02-20-2003 08:19 PM
what is the use of Environment variables indianguru UNIX for Dummies Questions & Answers 2 07-24-2001 09:41 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-10-2006
sumsin sumsin is offline
Registered User
  
 

Join Date: Nov 2005
Posts: 25
environment variables

hi,

I want to create a new EV(Environment Variable) through a c program and I done this thing through setenv() method. But the newly created EV is not permanent, i.e. when I exit from the program the EV also no longer lives. But I want to make it a permanent EV for the current user. Actually I am getting all the environment variables through envp (the environment variable pointer, it is the list of all the EVs).

thanks & regards
sumsin.
  #2 (permalink)  
Old 03-10-2006
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,717
It is not possible to create an environment variable in a child proces (what you are in when you are running code) and have the parent shell be able to see it. Once the code exits, the variable is gone with the defunct process.
  #3 (permalink)  
Old 03-10-2006
sumsin sumsin is offline
Registered User
  
 

Join Date: Nov 2005
Posts: 25
but what I am thinking that ... I write these variables in one of my private file say ".myprogram_profile" at $HOME dir, then source this private file in .bash_profile so that the newly created variables comes in effect.

am i right?
or i should think some other approach.
what do u say?

thanks & regards
sumsin
  #4 (permalink)  
Old 03-10-2006
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,717
The reason source works: it runs the script in the same (parent) process. So when it's done with the sourced script the variables are still there.

Yes, put the script in your profile.
  #5 (permalink)  
Old 03-13-2006
matrixmadhan matrixmadhan is online now Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,951
Quote:
Originally Posted by jim mcnamara
The reason source works: it runs the script in the same (parent) process. So when it's done with the sourced script the variables are still there.

Yes, put the script in your profile.
I think,
though the variables are available they are in effect only to the child(running process which created the EV variables) and not in effect to the parent ( shell ) which forked by the child.

Wont the newly added Env variables be effected with respect to the parent only after running the .profile ----> .$HOME/.profile?
  #6 (permalink)  
Old 03-13-2006
sumsin sumsin is offline
Registered User
  
 

Join Date: Nov 2005
Posts: 25
but is there any other way to do so?
Because when I create a variable two or more times it is added that many time in the file.
And I also wnat to edit the variables through my program...
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:16 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0