* some queris on .profile file
@ 2006-06-15 10:15 mehaboob
2006-06-15 12:37 ` Wim Cossement
2006-06-15 19:55 ` Adam Price
0 siblings, 2 replies; 14+ messages in thread
From: mehaboob @ 2006-06-15 10:15 UTC (permalink / raw)
Hi,
I have created a new user on .profile file and was modifying the
.profile file.but I do find some of the things while I login which
confuses me.
Here is my .profile
------------------------------------------------------------------------------------------------------
EDITOR=vi
export EDITOR
PATH=$HOME/bin:/usr/sbin:/usr/atria/bin:/usr/opt/temip/bin:${PATH:-/usr/bin:.}
export PATH
/usr/bin/ksh
# My customisations
TERM=vt100
HISTFILE=~/.history
HISTSIZE=300
#set -o emacs
alias ct='cleartool'
alias __A="^P"
alias __B="^N"
alias __C="^F"
alias __D="^B"
alias __H="^H"
------------------------------------------------------------------------------------------------------
1)whats the use of {PATH:-/usr/bin:.}
I mean "-/usr/bin"............?
2)/usr/bin/ksh
Are we changing the shell here?
whats the need to change the shell?
3)How do i determine which shell I am working on?
4)How do I change to some other shell?
5)And the above aliases doesnt get set while added in the
profile...why?
6) #set -o emacs
Do we need this emacs setting?
Thanks in advance
Mehaboob
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: some queris on .profile file 2006-06-15 10:15 some queris on .profile file mehaboob @ 2006-06-15 12:37 ` Wim Cossement 2006-06-15 19:55 ` Adam Price 1 sibling, 0 replies; 14+ messages in thread From: Wim Cossement @ 2006-06-15 12:37 UTC (permalink / raw) mehaboob@gmail.com wrote: > Hi, > > I have created a new user on .profile file and was modifying the > .profile file.but I do find some of the things while I login which > confuses me. > > Here is my .profile > ------------------------------------------------------------------------------------------------------ > EDITOR=vi > export EDITOR > PATH=$HOME/bin:/usr/sbin:/usr/atria/bin:/usr/opt/temip/bin:${PATH:-/usr/bin:.} > export PATH > > /usr/bin/ksh > # My customisations > TERM=vt100 > HISTFILE=~/.history > HISTSIZE=300 > #set -o emacs > alias ct='cleartool' > alias __A="^P" > alias __B="^N" > alias __C="^F" > alias __D="^B" > alias __H="^H" > ------------------------------------------------------------------------------------------------------ > > 1)whats the use of {PATH:-/usr/bin:.} > I mean "-/usr/bin"............? No idea, normally this should not be there, just ommit it. > 2)/usr/bin/ksh > Are we changing the shell here? > whats the need to change the shell? Some people prefer another shell, I like bash the most... Different shells have slightly different syntaxes and functionality. > 3)How do i determine which shell I am working on? > 4)How do I change to some other shell? If you type the set command you shoud get a list of all the variables that are currently set. Look for the one called SHELL Normally programs look for that one, and this should not changed when you ware for example in bash and run /usr/bin/ksh. Your default shell is set in /etc/passwd where you can change it (or on your NIS or LDAP server if you use that for authentication) More info here: http://www.codecoffee.com/tipsforlinux/articles/030.html > 5)And the above aliases doesnt get set while added in the > profile...why? Don't know, they look like escape characters to me, I don't realy think they are necessary. > 6) #set -o emacs > Do we need this emacs setting? If a line starts with the #, it's comment and thus ignored. > Thanks in advance > Mehaboob > HTH, Wimmy -- Being owned by someone used to be called slavery. Now it's called commitment. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: some queris on .profile file 2006-06-15 10:15 some queris on .profile file mehaboob 2006-06-15 12:37 ` Wim Cossement @ 2006-06-15 19:55 ` Adam Price 2006-06-16 9:15 ` mehaboob 1 sibling, 1 reply; 14+ messages in thread From: Adam Price @ 2006-06-15 19:55 UTC (permalink / raw) On 15 Jun 2006 03:15:58 -0700, mehaboob@gmail.com wrote: > Hi, > > I have created a new user on .profile file and was modifying the > .profile file.but I do find some of the things while I login which > confuses me. > > Here is my .profile > ------------------------------------------------------------------------------------------------------ > EDITOR=vi > export EDITOR > PATH=$HOME/bin:/usr/sbin:/usr/atria/bin:/usr/opt/temip/bin:${PATH:-/usr/bin:.} > export PATH > > /usr/bin/ksh > # My customisations > TERM=vt100 > HISTFILE=~/.history > HISTSIZE=300 > #set -o emacs > alias ct='cleartool' > alias __A="^P" > alias __B="^N" > alias __C="^F" > alias __D="^B" > alias __H="^H" > ------------------------------------------------------------------------------------------------------ > > 1)whats the use of {PATH:-/usr/bin:.} > I mean "-/usr/bin"............? This is a ksh construct, from the man page for ksh... ${parameter:-word} Substitutes the value of parameter if it is set and non-null; otherwise, substitute word. So what this does is add some values to the beginning of $PATH > > 2)/usr/bin/ksh > Are we changing the shell here? > whats the need to change the shell? > Yes you are, however there is no need to change shell, you should set it correctly in /etc/passwd in the first place. > 3)How do i determine which shell I am working on? Try doing something that you can do in sh but not in ksh, like ls -l /etc ^ more In sh that will pipe the output from ls -l /etc into more, in ksh it won't. > 4)How do I change to some other shell? To change permanently either ask your sysadmin, or if you are the sysadmin, read the man page for passwd and vipw. > 5)And the above aliases doesnt get set while added in the > profile...why? Because when you execute /usr/bin/ksh then it executes, this is the shell you are running in, at that point your .profile hasn't gotten to the bit with the aliases. > 6) #set -o emacs > Do we need this emacs setting? It is commented out, it does nothing. However it may give the same result as the aliases lower down (which are for allowing the arrow keys to work). Hope that helps Adam ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: some queris on .profile file 2006-06-15 19:55 ` Adam Price @ 2006-06-16 9:15 ` mehaboob 2006-06-16 15:27 ` Wim Cossement 0 siblings, 1 reply; 14+ messages in thread From: mehaboob @ 2006-06-16 9:15 UTC (permalink / raw) Adam Price wrote: > On 15 Jun 2006 03:15:58 -0700, mehaboob@gmail.com wrote: > > > Hi, > > > > I have created a new user on .profile file and was modifying the > > .profile file.but I do find some of the things while I login which > > confuses me. > > > > Here is my .profile > > ------------------------------------------------------------------------------------------------------ > > EDITOR=vi > > export EDITOR > > PATH=$HOME/bin:/usr/sbin:/usr/atria/bin:/usr/opt/temip/bin:${PATH:-/usr/bin:.} > > export PATH > > > > /usr/bin/ksh > > # My customisations > > TERM=vt100 > > HISTFILE=~/.history > > HISTSIZE=300 > > #set -o emacs > > alias ct='cleartool' > > alias __A="^P" > > alias __B="^N" > > alias __C="^F" > > alias __D="^B" > > alias __H="^H" > > ------------------------------------------------------------------------------------------------------ > > > > 1)whats the use of {PATH:-/usr/bin:.} > > I mean "-/usr/bin"............? > This is a ksh construct, from the man page for ksh... > > ${parameter:-word} > Substitutes the value of parameter if it is set and non-null; > otherwise, substitute word. > > So what this does is add some values to the beginning of $PATH > > > > > 2)/usr/bin/ksh > > Are we changing the shell here? > > whats the need to change the shell? > > > Yes you are, however > there is no need to change shell, you should set it correctly in > /etc/passwd in the first place. > > > 3)How do i determine which shell I am working on? > Try doing something that you can do in sh but not in ksh, like > ls -l /etc ^ more > In sh that will pipe the output from ls -l /etc into more, in ksh it won't. > > > > 4)How do I change to some other shell? > To change permanently either ask your sysadmin, or if you are the sysadmin, > read the man page for passwd and vipw. > > > 5)And the above aliases doesnt get set while added in the > > profile...why? > Because when you execute /usr/bin/ksh then it executes, this is the shell > you are running in, at that point your .profile hasn't gotten to the bit > with the aliases. > > > > 6) #set -o emacs > > Do we need this emacs setting? > It is commented out, it does nothing. However it may give the same result > as the aliases lower down (which are for allowing the arrow keys to work). > > Hope that helps > Adam Hi, Thanks for the reply. Currently I have modified the .profile. EDITOR=vi export EDITOR PATH=$HOME/bin:/usr/sbin:/usr/atria/bin:/usr/opt/temip/bin:${PATH:-/usr/bin:.} export PATH # My customisations TERM=vt100 HISTFILE=~/.history HISTSIZE=300 #set -o emacs alias ct='cleartool' alias __A="^P" alias __B="^N" alias __C="^F" alias __D="^B" alias __H="^H" alias __P="^P" export TERM HISTFILE HISTSIZE 1)But still the aliases dont work and dunno why? 2)And also in order to execute the profile i type, $. ./.profile Could you explain what all these dot means i.e <dot space dot/dotprofile> Mehaboob ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: some queris on .profile file 2006-06-16 9:15 ` mehaboob @ 2006-06-16 15:27 ` Wim Cossement 2006-06-17 18:21 ` mehaboob 0 siblings, 1 reply; 14+ messages in thread From: Wim Cossement @ 2006-06-16 15:27 UTC (permalink / raw) mehaboob@gmail.com wrote: > Adam Price wrote: > >> On 15 Jun 2006 03:15:58 -0700, mehaboob@gmail.com wrote: >> >>> Hi, >>> >>> I have created a new user on .profile file and was modifying the >>> .profile file.but I do find some of the things while I login which >>> confuses me. >>> >>> Here is my .profile >>> ------------------------------------------------------------------------------------------------------ >>> EDITOR=vi >>> export EDITOR >>> PATH=$HOME/bin:/usr/sbin:/usr/atria/bin:/usr/opt/temip/bin:${PATH:-/usr/bin:.} >>> export PATH >>> >>> /usr/bin/ksh >>> # My customisations >>> TERM=vt100 >>> HISTFILE=~/.history >>> HISTSIZE=300 >>> #set -o emacs >>> alias ct='cleartool' >>> alias __A="^P" >>> alias __B="^N" >>> alias __C="^F" >>> alias __D="^B" >>> alias __H="^H" >>> ------------------------------------------------------------------------------------------------------ >>> >>> 1)whats the use of {PATH:-/usr/bin:.} >>> I mean "-/usr/bin"............? >> This is a ksh construct, from the man page for ksh... >> >> ${parameter:-word} >> Substitutes the value of parameter if it is set and non-null; >> otherwise, substitute word. >> >> So what this does is add some values to the beginning of $PATH >> >>> 2)/usr/bin/ksh >>> Are we changing the shell here? >>> whats the need to change the shell? >>> >> Yes you are, however >> there is no need to change shell, you should set it correctly in >> /etc/passwd in the first place. >> >>> 3)How do i determine which shell I am working on? >> Try doing something that you can do in sh but not in ksh, like >> ls -l /etc ^ more >> In sh that will pipe the output from ls -l /etc into more, in ksh it won't. >> >> >>> 4)How do I change to some other shell? >> To change permanently either ask your sysadmin, or if you are the sysadmin, >> read the man page for passwd and vipw. >> >>> 5)And the above aliases doesnt get set while added in the >>> profile...why? >> Because when you execute /usr/bin/ksh then it executes, this is the shell >> you are running in, at that point your .profile hasn't gotten to the bit >> with the aliases. >> >> >>> 6) #set -o emacs >>> Do we need this emacs setting? >> It is commented out, it does nothing. However it may give the same result >> as the aliases lower down (which are for allowing the arrow keys to work). >> >> Hope that helps >> Adam > > Hi, > > Thanks for the reply. > > Currently I have modified the .profile. > > EDITOR=vi > export EDITOR > PATH=$HOME/bin:/usr/sbin:/usr/atria/bin:/usr/opt/temip/bin:${PATH:-/usr/bin:.} > export PATH > > # My customisations > TERM=vt100 > HISTFILE=~/.history > HISTSIZE=300 > #set -o emacs > alias ct='cleartool' > alias __A="^P" > alias __B="^N" > alias __C="^F" > alias __D="^B" > alias __H="^H" > alias __P="^P" > export TERM HISTFILE HISTSIZE > > 1)But still the aliases dont work and dunno why? > 2)And also in order to execute the profile i type, > $. ./.profile > > Could you explain what all these dot means i.e > <dot space dot/dotprofile> Well I dont know exactly but the $. i guess would be your prompt (but read the ksh manfile to be sure ;-) Files starting with . are hidden files; if you do an ls you won't normally see them, you have to do ls -a to see them (-a means show everything). If you do so you might also notice a . and a .. The . indicates your current directory, and .. is the parent directory. So ./.profile means executing the hidden file profile in your current directory Wimmy > > Mehaboob > -- Being owned by someone used to be called slavery. Now it's called commitment. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: some queris on .profile file 2006-06-16 15:27 ` Wim Cossement @ 2006-06-17 18:21 ` mehaboob 2006-06-17 18:56 ` Piotr Hosowicz 0 siblings, 1 reply; 14+ messages in thread From: mehaboob @ 2006-06-17 18:21 UTC (permalink / raw) Wim Cossement wrote: > mehaboob@gmail.com wrote: > > Adam Price wrote: > > > >> On 15 Jun 2006 03:15:58 -0700, mehaboob@gmail.com wrote: > >> > >>> Hi, > >>> > >>> I have created a new user on .profile file and was modifying the > >>> .profile file.but I do find some of the things while I login which > >>> confuses me. > >>> > >>> Here is my .profile > >>> ------------------------------------------------------------------------------------------------------ > >>> EDITOR=vi > >>> export EDITOR > >>> PATH=$HOME/bin:/usr/sbin:/usr/atria/bin:/usr/opt/temip/bin:${PATH:-/usr/bin:.} > >>> export PATH > >>> > >>> /usr/bin/ksh > >>> # My customisations > >>> TERM=vt100 > >>> HISTFILE=~/.history > >>> HISTSIZE=300 > >>> #set -o emacs > >>> alias ct='cleartool' > >>> alias __A="^P" > >>> alias __B="^N" > >>> alias __C="^F" > >>> alias __D="^B" > >>> alias __H="^H" > >>> ------------------------------------------------------------------------------------------------------ > >>> > >>> 1)whats the use of {PATH:-/usr/bin:.} > >>> I mean "-/usr/bin"............? > >> This is a ksh construct, from the man page for ksh... > >> > >> ${parameter:-word} > >> Substitutes the value of parameter if it is set and non-null; > >> otherwise, substitute word. > >> > >> So what this does is add some values to the beginning of $PATH > >> > >>> 2)/usr/bin/ksh > >>> Are we changing the shell here? > >>> whats the need to change the shell? > >>> > >> Yes you are, however > >> there is no need to change shell, you should set it correctly in > >> /etc/passwd in the first place. > >> > >>> 3)How do i determine which shell I am working on? > >> Try doing something that you can do in sh but not in ksh, like > >> ls -l /etc ^ more > >> In sh that will pipe the output from ls -l /etc into more, in ksh it won't. > >> > >> > >>> 4)How do I change to some other shell? > >> To change permanently either ask your sysadmin, or if you are the sysadmin, > >> read the man page for passwd and vipw. > >> > >>> 5)And the above aliases doesnt get set while added in the > >>> profile...why? > >> Because when you execute /usr/bin/ksh then it executes, this is the shell > >> you are running in, at that point your .profile hasn't gotten to the bit > >> with the aliases. > >> > >> > >>> 6) #set -o emacs > >>> Do we need this emacs setting? > >> It is commented out, it does nothing. However it may give the same result > >> as the aliases lower down (which are for allowing the arrow keys to work). > >> > >> Hope that helps > >> Adam > > > > Hi, > > > > Thanks for the reply. > > > > Currently I have modified the .profile. > > > > EDITOR=vi > > export EDITOR > > PATH=$HOME/bin:/usr/sbin:/usr/atria/bin:/usr/opt/temip/bin:${PATH:-/usr/bin:.} > > export PATH > > > > # My customisations > > TERM=vt100 > > HISTFILE=~/.history > > HISTSIZE=300 > > #set -o emacs > > alias ct='cleartool' > > alias __A="^P" > > alias __B="^N" > > alias __C="^F" > > alias __D="^B" > > alias __H="^H" > > alias __P="^P" > > export TERM HISTFILE HISTSIZE > > > > 1)But still the aliases dont work and dunno why? > > 2)And also in order to execute the profile i type, > > $. ./.profile > > > > Could you explain what all these dot means i.e > > <dot space dot/dotprofile> > > Well I dont know exactly but the $. i guess would be your prompt (but > read the ksh manfile to be sure ;-) > > Files starting with . are hidden files; if you do an ls you won't > normally see them, you have to do ls -a to see them (-a means show > everything). > If you do so you might also notice a . and a .. > The . indicates your current directory, and .. is the parent directory. > > So ./.profile means executing the hidden file profile in your current > directory > > Wimmy > > > > Mehaboob > > > > > -- > Being owned by someone used to be called slavery. Hi, Thanks for your reply. I did understand about your explanation for ./.profile But what is the initail dot and space for? i.e . ./.profile Mehaboob > Now it's called commitment. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: some queris on .profile file 2006-06-17 18:21 ` mehaboob @ 2006-06-17 18:56 ` Piotr Hosowicz 2006-06-17 20:38 ` mehaboob 0 siblings, 1 reply; 14+ messages in thread From: Piotr Hosowicz @ 2006-06-17 18:56 UTC (permalink / raw) 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, meaning "including" the script some-script.sh. There are some gotchas, like for example if you have : exit .. in some-script.sh then it will exit the whole calling shell and 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. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: some queris on .profile file 2006-06-17 18:56 ` Piotr Hosowicz @ 2006-06-17 20:38 ` mehaboob 2006-06-17 22:07 ` Piotr Hosowicz 2006-06-18 1:21 ` Bob Harris 0 siblings, 2 replies; 14+ messages in thread From: mehaboob @ 2006-06-17 20:38 UTC (permalink / raw) 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, meaning > "including" the script some-script.sh. There are some gotchas, like for > example if you have : > > exit > > .. in some-script.sh then it will exit the whole calling shell and 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 <filename> i.e source .profile If I have execute .profile then the command would be ./<filename> i.e ./.profile But my confusion why do we have source and execute source execute the file i.e souce ./<filename> i.e . ./.profile Regards, Mehaboob ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: some queris on .profile file 2006-06-17 20:38 ` mehaboob @ 2006-06-17 22:07 ` Piotr Hosowicz 2006-06-18 1:21 ` Bob Harris 1 sibling, 0 replies; 14+ messages in thread From: Piotr Hosowicz @ 2006-06-17 22:07 UTC (permalink / raw) mehaboob@gmail.com wrote: > if we apply the rules source some-script.sh then we get > source <filename> i.e > source .profile > > If I have execute .profile then the command would be > ./<filename> i.e > ./.profile > > But my confusion why do we have source and execute > source execute the file i.e > souce ./<filename> i.e > . ./.profile Once again - source-inclusion or dot-inclusion are the same and happen in the same shell, that you are running and issuing the source-include or dot-include command. When some-script.sh is executable and you do : ./some-script.sh ... then execution happens in a separate shell, unlike in source-inclusion or dot-inclusion. That's why I mentioned exit command. Frequently people keep asking why their source/dot included scripts end prematurely. Usually this happens when there's an exit in included (sourced) file. -- No signature found. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: some queris on .profile file 2006-06-17 20:38 ` mehaboob 2006-06-17 22:07 ` Piotr Hosowicz @ 2006-06-18 1:21 ` Bob Harris 2006-06-18 15:33 ` mehaboob 1 sibling, 1 reply; 14+ messages in thread From: Bob Harris @ 2006-06-18 1:21 UTC (permalink / raw) [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain, Size: 2147 bytes --] In article <1150576687.026459.179060@u72g2000cwu.googlegroups.com>, "mehaboob@gmail.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, meaning > > "including" the script some-script.sh. There are some gotchas, like for > > example if you have : > > > > exit > > > > .. in some-script.sh then it will exit the whole calling shell and 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 <filename> i.e > source .profile > > If I have execute .profile then the command would be > ./<filename> i.e > ./.profile > > But my confusion why do we have source and execute > source execute the file i.e > souce ./<filename> 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�tit :-) Bob Harris ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: some queris on .profile file 2006-06-18 1:21 ` Bob Harris @ 2006-06-18 15:33 ` mehaboob 2006-06-18 17:57 ` Bob Harris 0 siblings, 1 reply; 14+ messages in thread From: mehaboob @ 2006-06-18 15:33 UTC (permalink / raw) Bob Harris wrote: > In article > <1150576687.026459.179060@u72g2000cwu.googlegroups.com>, > "mehaboob@gmail.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, meaning > > > "including" the script some-script.sh. There are some gotchas, like for > > > example if you have : > > > > > > exit > > > > > > .. in some-script.sh then it will exit the whole calling shell and 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 <filename> i.e > > source .profile > > > > If I have execute .profile then the command would be > > ./<filename> i.e > > ./.profile > > > > But my confusion why do we have source and execute > > source execute the file i.e > > souce ./<filename> 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étit :-) > > 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? 2)Are the environment available for all the script intiated from the shell? 3)Is it possible that the .profile does not get sourced when I login ? 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? Mehaboob ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: some queris on .profile file 2006-06-18 15:33 ` mehaboob @ 2006-06-18 17:57 ` Bob Harris 2006-06-18 21:24 ` mehaboob 0 siblings, 1 reply; 14+ messages in thread From: Bob Harris @ 2006-06-18 17:57 UTC (permalink / raw) [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain, Size: 7700 bytes --] In article <1150644822.914802.41470@r2g2000cwb.googlegroups.com>, "mehaboob@gmail.com" <mehaboob@gmail.com> wrote: > Bob Harris wrote: > > > In article > > <1150576687.026459.179060@u72g2000cwu.googlegroups.com>, > > "mehaboob@gmail.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, meaning > > > > "including" the script some-script.sh. There are some gotchas, like for > > > > example if you have : > > > > > > > > exit > > > > > > > > .. in some-script.sh then it will exit the whole calling shell and 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 <filename> i.e > > > source .profile > > > > > > If I have execute .profile then the command would be > > > ./<filename> i.e > > > ./.profile > > > > > > But my confusion why do we have source and execute > > > source execute the file i.e > > > souce ./<filename> 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�tit :-) > > > > 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='value' export variable_name or export variable_name='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 ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: some queris on .profile file 2006-06-18 17:57 ` Bob Harris @ 2006-06-18 21:24 ` mehaboob 2006-06-19 0:57 ` Bob Harris 0 siblings, 1 reply; 14+ messages in thread From: mehaboob @ 2006-06-18 21:24 UTC (permalink / raw) Bob Harris wrote: > In article <1150644822.914802.41470@r2g2000cwb.googlegroups.com>, > "mehaboob@gmail.com" <mehaboob@gmail.com> wrote: > > > Bob Harris wrote: > > > > > In article > > > <1150576687.026459.179060@u72g2000cwu.googlegroups.com>, > > > "mehaboob@gmail.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, meaning > > > > > "including" the script some-script.sh. There are some gotchas, like for > > > > > example if you have : > > > > > > > > > > exit > > > > > > > > > > .. in some-script.sh then it will exit the whole calling shell and 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 <filename> i.e > > > > source .profile > > > > > > > > If I have execute .profile then the command would be > > > > ./<filename> i.e > > > > ./.profile > > > > > > > > But my confusion why do we have source and execute > > > > source execute the file i.e > > > > souce ./<filename> 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étit :-) > > > > > > 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='value' > export variable_name > or > export variable_name='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 ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: some queris on .profile file 2006-06-18 21:24 ` mehaboob @ 2006-06-19 0:57 ` Bob Harris 0 siblings, 0 replies; 14+ messages in thread From: Bob Harris @ 2006-06-19 0:57 UTC (permalink / raw) [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain, Size: 9645 bytes --] In article <1150665868.779077.294420@y41g2000cwy.googlegroups.com>, "mehaboob@gmail.com" <mehaboob@gmail.com> wrote: > Bob Harris wrote: > > > In article <1150644822.914802.41470@r2g2000cwb.googlegroups.com>, > > "mehaboob@gmail.com" <mehaboob@gmail.com> wrote: > > > > > Bob Harris wrote: > > > > > > > In article > > > > <1150576687.026459.179060@u72g2000cwu.googlegroups.com>, > > > > "mehaboob@gmail.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, > > > > > > meaning > > > > > > "including" the script some-script.sh. There are some gotchas, like > > > > > > for > > > > > > example if you have : > > > > > > > > > > > > exit > > > > > > > > > > > > .. in some-script.sh then it will exit the whole calling shell and > > > > > > 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 <filename> i.e > > > > > source .profile > > > > > > > > > > If I have execute .profile then the command would be > > > > > ./<filename> i.e > > > > > ./.profile > > > > > > > > > > But my confusion why do we have source and execute > > > > > source execute the file i.e > > > > > souce ./<filename> 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�tit :-) > > > > > > > > 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='value' > > export variable name > > or > > export variable name='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 Then for your quest, I highly recommend "The UNIX Programming Environment" by Kernighan and Pike. It is copyright 1984 (I think), but I still think it is one of the best books for explaining the command line, beginning shell scripts, pipes, etc... You do not need to read all of it, as it goes into C programming more, but the first 5 or 6 chapters are great for most UNIX users that want to get into scripting. It will provide a lot of the foundation. Just keep in mind that UNIX and friends have more forward a lot since 1984, so there are more features in shells, and utilities. Good luck. Bob Harris ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2006-06-19 0:57 UTC | newest] Thread overview: 14+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2006-06-15 10:15 some queris on .profile file mehaboob 2006-06-15 12:37 ` Wim Cossement 2006-06-15 19:55 ` Adam Price 2006-06-16 9:15 ` mehaboob 2006-06-16 15:27 ` Wim Cossement 2006-06-17 18:21 ` mehaboob 2006-06-17 18:56 ` Piotr Hosowicz 2006-06-17 20:38 ` mehaboob 2006-06-17 22:07 ` Piotr Hosowicz 2006-06-18 1:21 ` Bob Harris 2006-06-18 15:33 ` mehaboob 2006-06-18 17:57 ` Bob Harris 2006-06-18 21:24 ` mehaboob 2006-06-19 0:57 ` Bob Harris
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox