From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Thread: fa528,1fcb2333482dcee6 X-Google-Attributes: gidfa528,public X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!y41g2000cwy.googlegroups.com!not-for-mail From: "mehaboob@gmail.com" Newsgroups: comp.unix.tru64 Subject: Re: some queris on .profile file Date: 18 Jun 2006 14:24:28 -0700 Organization: http://groups.google.com Message-ID: <1150665868.779077.294420@y41g2000cwy.googlegroups.com> References: <1150366558.414200.141250@p79g2000cwp.googlegroups.com> <1150449352.642566.101720@c74g2000cwc.googlegroups.com> <1150568477.954146.133060@f6g2000cwb.googlegroups.com> <1150576687.026459.179060@u72g2000cwu.googlegroups.com> <1150644822.914802.41470@r2g2000cwb.googlegroups.com> NNTP-Posting-Host: 62.253.96.45 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1150665874 2732 127.0.0.1 (18 Jun 2006 21:24:34 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 18 Jun 2006 21:24:34 +0000 (UTC) In-Reply-To: User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; FunWebProducts; .NET CLR 1.0.3705; .NET CLR 1.1.4322; .NET CLR 2.0.50727),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: y41g2000cwy.googlegroups.com; posting-host=62.253.96.45; posting-account=t-Pqjw0AAAD1wih1fRxEyfEQBPguK2ZN Xref: g2news2.google.com comp.unix.tru64:435 Bob Harris wrote: > In article <1150644822.914802.41470@r2g2000cwb.googlegroups.com>, > "mehaboob@gmail.com" wrote: > > > Bob Harris wrote: > > > > > In article > > > <1150576687.026459.179060@u72g2000cwu.googlegroups.com>, > > > "mehaboob@gmail.com" wrote: > > > > > > > Piotr Hosowicz wrote: > > > > > > > > > mehaboob@gmail.com wrote: > > > > > > > > > > > I did understand about your explanation for ./.profile > > > > > > But what is the initail dot and space for? > > > > > > i.e . ./.profile > > > > > > > > > > Hi Mehaboob, > > > > > > > > > > In some shells there is a command named source, if you do : > > > > > > > > > > source some-script.sh > > > > > > > > > > ... then some-script.sh is sourced into current running shell, me= aning > > > > > "including" the script some-script.sh. There are some gotchas, li= ke for > > > > > example if you have : > > > > > > > > > > exit > > > > > > > > > > .. in some-script.sh then it will exit the whole calling shell an= d not > > > > > terminate "sourceing" some-script.sh. > > > > > > > > > > Single dot is equivalent to source'ing some script, so above is > > > > > equivalent to : > > > > > > > > > > . some-script.sh > > > > > > > > > > > > > > > -- > > > > > No signature found. > > > > > > > > Thanks for taking time to explain. > > > > I have some more confusion > > > > > > > > > > > > if we apply the rules source some-script.sh then we get > > > > source i.e > > > > source .profile > > > > > > > > If I have execute .profile then the command would be > > > > ./ i.e > > > > ./.profile > > > > > > > > But my confusion why do we have source and execute > > > > source execute the file i.e > > > > souce ./ i.e > > > > . ./.profile > > > > > > > > > > > > Regards, > > > > Mehaboob > > > > > > Sourcing a script (eg: . ./.profile) will allow tht script to set > > > local variables, environment variables, shell options, aliases, > > > create functions, etc... for your running shell. In this case it > > > would be your interactive shell. So it can alter your current > > > shell environment. > > > > > > Invoking an executable shell (eg: ./.profile) will run that shell > > > script in a subprocess. All variables, environment variables, > > > shell options, aliases, and functions created or modified will be > > > lost as soon as that script finishes. > > > > > > Think of it as going to dinner with a friend, and your buying. > > > You both consuem food, but when your friend leaves, the calories > > > he/she consumed, leaves with them. But the calories you ate get > > > to go home with your. Bon App=E9tit :-) > > > > > > Bob Harris > > > > > > Hi, > > > > Thanks for the explanation.Now this brings up some queries in my > > mind.... > > > > 1)What are environment variables?...Are these the only variables that > > are set in .profile file? > > You should really REALLY think about going out to your local book > store, get something to drink in the cafe, and browse some of the > UNIX for MacOSX users books, or even a few of the Linux or UNIX > shell related books. Just page through the first few chapters and > they should give you a feel for some of the shell basics. > > Environment variables are values that get passed to subprocesses > that are created. For example, your PATH is an environment > variable, and it is a colon separated list of directories where > all the executable programs you want to be able to run by just > typing the file name are to be found. The order of the > directories is the order that they are searched. If there are > duplicate scripts or executables, the first one found is used. > > So using PATH as an environment variable example, you can set PATH > to include additional directories, and then when you run scripts, > they can find your commands as well as the other commands > available via PATH. > > Environment variables are only passed down. Changes made to an > environment variable in a subprocess is never returned to the > parent process. > > Environment variables are set in bourne shell, korn shell, bash, > zsh, POSIX shell, or other shells derived from the bourne shell > using > > variable_name=3D'value' > export variable_name > or > export variable_name=3D'value' > > The C shell and tcsh environment variables are set using: > > setenv variable_name 'value' > > .profile (used by bourne shell derived shells) is the general > place to set environment variables that you want to always have > when you login. They can be set other ways, especially if you > have a script or program that needs additional or different values > from what is established during your login. Generally the scripts > or programs would make their own modifications as needed. There > are a few other ways to actually set environment variables, but I > think we can skip them for now, as they are less interesting to > your needs. A good book on the shell you are using would cover > this if by some remote possibility you would really need this. > > In addition to .profile, there is generally a /etc/profile that is > invoked for every bourn shell that logs in. A global for all > users that use bourne shells. > > If you are a csh or tcsh user, then there are similar but > differently named initialization files .login, .cshrc, .tcshrc, > /etc/csh.login, /etc/csh.cshrc > > And some environment variables are created by the shell itself > when it starts up. > > And it is possible that the process the accepts your username and > password, and starts up your shell, may pass along some > environment variables. > > Local shell variables may be set in .profile. These would be used > by the shell itself. For example HISTSIZE, MAILCHECK, IGNOREEOF, > etc... are local shell variables that control the behavior of your > interactive shell. The man page for your shell should be able to > list a lot of the variables that may be of interest. > > Since most bourne shells can have local functions, you can have > local variables that either maintain state or control their > behavior. Since these are user created local functions, what > variables and what they do is up to you the creator of those local > functions. > > You asked a simple question, and you get an hour long class :-) > > > > 2)Are the environment available for all the script intiated from the > > shell? > > Yes. Environment variables are passed down the parent/child > chain. > > But again, they only go down. Modifications to environment > variables in a child only get passed to their children, never back > to their parents. > > > 3)Is it possible that the .profile does not get sourced when I login ? > > Unlikely. Too many UNIX users in the world depend on this. > > However, if your shell is really bash, then it first looks for > .bash_profile, then .bash_login, then .profile. First one found > it executed. The remainder are ignored, unless you have commands > in the one that does get executed to source the others. > > > 4)When I run the command env,variables listed...Are these the variables > > that are set using .profile ,if not where are these variables being > > set? > > As stated above, they could be set by the process that creates > your login shell (the one that logs you in), they could be set by > /etc/profile, and the shell itself might create a few. > > You can remove an environment variable using unset > > unset some_env_var > > But be careful that you do not mess things up for yourself. > Screwing up PATH can be a pain. Not fatal, but very annoying. > > > Mehaboob > > Again, it is time to visit the bookstore. Browse some UNIX for > MacOSX books. Browse some UNIX and Linux books on shells (bash is > the default shell on MacOSX). After drinking several cafe drinks > you find one you like and want to read more, buy it. Otherwise > keep buying cafe drinks (bookstore has to make money some how :-) ) > > Bob Harris Thanks a million for such an amazing explanation. I am an experienced unix user...but nowardays i have this quest to understand anything and everthing related to unix...somehow i fantasise about being some unix geek. My quest has just started and I hope I dont take much time to master it! Any comments and suggestions welcome! Mehaboob