2011-08-04 17:38:32     sourcing a file from /etc/rc

Document created by Aaronwu Employee on Aug 27, 2013
Version 1Show Document
  • View in full screen mode

2011-08-04 17:38:32     sourcing a file from /etc/rc

Timur Aydin (TURKEY)

Message: 102818   

 

When I source a file from /etc/rc like this:

 

. /etc/somefile

 

the variables defined in /etc/somefile do not persist after /etc/rc has exited. But when I source /etc/profile, they do persist. So in order to define additional variables, I have to append those lines to /etc/profile and source it again. I really don't want to do this, because I want to change the root filesystem to be read only. The fact that variables are persistent only if they are sourced from /etc/profile, is this a bug or is this by design?

QuoteReplyEditDelete

 

 

2011-08-04 22:50:31     Re: sourcing a file from /etc/rc

Aaron Wu (CHINA)

Message: 102821   

 

What do you mean by persist? Could you give some sample shell scripts to explain this?

QuoteReplyEditDelete

 

 

2011-08-05 03:33:17     Re: sourcing a file from /etc/rc

Timur Aydin (TURKEY)

Message: 102830   

 

Sorry for being a little vague. There are some environment variables that I want to be set after the blackfin boot it complete. If I set an environment variable in /etc/rc like this:

 

export SOMEVAR="Value"

 

I find that this variable isn't set after boot is complete. The only way for it to be set after boot is complete is if I add that variable into /etc/profile and source this file from within /etc/rc. Or, I have to append the variable to /etc/profile and re-source it after that. Problem is, the rootfs will be a read only filesystem, so appending isn't an option.

 

Basically, I am looking for a way to export an environment variable from within /etc/rc and have that variable exist after /etc/rc exist and the boot completes with the command prompt.

QuoteReplyEditDelete

 

 

2011-08-05 04:49:03     Re: sourcing a file from /etc/rc

Aaron Wu (CHINA)

Message: 102832   

 

Thanks for clarification.

 

I don't understand how your modification to the scripts can be saved if it's a Read only filesystem? why not use R/W filesystem.

 

The reason that lines in /etc/profile can be seen by all the shell process is because the /etc/profile is global to all of the shell process, you may find more information by googling /etc/profile, there are plenty of document about it. While for /etc/rc, it's executed/started by a specific shell process, varibles exported in it are not globle to all the shell, although it can be acessed in sub shells.

Attachments

    Outcomes