niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » *nix » Tru64
some queris on .profile file
Post new topic   Reply to topic Page 1 of 1 [14 Posts] View previous topic :: View next topic
Author Message
Bob Harris
*nix forums beginner


Joined: 23 Mar 2005
Posts: 39

PostPosted: Mon Jun 19, 2006 12:57 am    Post subject: Re: some queris on .profile file Reply with quote

In article
<1150665868.779077.294420@y41g2000cwy.googlegroups.com>,
"mehaboob@gmail.com" <mehaboob@gmail.com> wrote:

Quote:
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 Smile )

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
Back to top
mehaboob@gmail.com
*nix forums beginner


Joined: 02 May 2006
Posts: 39

PostPosted: Sun Jun 18, 2006 9:24 pm    Post subject: Re: some queris on .profile file Reply with quote

Bob Harris wrote:

Quote:
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 Smile )

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
Back to top
Bob Harris
*nix forums beginner


Joined: 23 Mar 2005
Posts: 39

PostPosted: Sun Jun 18, 2006 5:57 pm    Post subject: Re: some queris on .profile file Reply with quote

In article <1150644822.914802.41470@r2g2000cwb.googlegroups.com>,
"mehaboob@gmail.com" <mehaboob@gmail.com> wrote:

Quote:
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 :-)


Quote:
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.

Quote:
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.

Quote:
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.

Quote:
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 Smile )

Bob Harris
Back to top
mehaboob@gmail.com
*nix forums beginner


Joined: 02 May 2006
Posts: 39

PostPosted: Sun Jun 18, 2006 3:33 pm    Post subject: Re: some queris on .profile file Reply with quote

Bob Harris wrote:

Quote:
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
Back to top
Bob Harris
*nix forums beginner


Joined: 23 Mar 2005
Posts: 39

PostPosted: Sun Jun 18, 2006 1:21 am    Post subject: Re: some queris on .profile file Reply with quote

In article
<1150576687.026459.179060@u72g2000cwu.googlegroups.com>,
"mehaboob@gmail.com" <mehaboob@gmail.com> wrote:

Quote:
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
Back to top
Piotr Hosowicz
*nix forums beginner


Joined: 08 Jun 2006
Posts: 12

PostPosted: Sat Jun 17, 2006 10:07 pm    Post subject: Re: some queris on .profile file Reply with quote

mehaboob@gmail.com wrote:

Quote:
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.
Back to top
mehaboob@gmail.com
*nix forums beginner


Joined: 02 May 2006
Posts: 39

PostPosted: Sat Jun 17, 2006 8:38 pm    Post subject: Re: some queris on .profile file Reply with quote

Piotr Hosowicz wrote:

Quote:
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
Back to top
Piotr Hosowicz
*nix forums beginner


Joined: 08 Jun 2006
Posts: 12

PostPosted: Sat Jun 17, 2006 6:56 pm    Post subject: Re: some queris on .profile file Reply with quote

mehaboob@gmail.com wrote:

Quote:
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.
Back to top
mehaboob@gmail.com
*nix forums beginner


Joined: 02 May 2006
Posts: 39

PostPosted: Sat Jun 17, 2006 6:21 pm    Post subject: Re: some queris on .profile file Reply with quote

Wim Cossement wrote:

Quote:
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.
Back to top
Wim Cossement
*nix forums Guru Wannabe


Joined: 24 Feb 2005
Posts: 173

PostPosted: Fri Jun 16, 2006 3:27 pm    Post subject: Re: some queris on .profile file Reply with quote

mehaboob@gmail.com wrote:
Quote:
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
Quote:

Mehaboob



--
Being owned by someone used to be called slavery.
Now it's called commitment.
Back to top
mehaboob@gmail.com
*nix forums beginner


Joined: 02 May 2006
Posts: 39

PostPosted: Fri Jun 16, 2006 9:15 am    Post subject: Re: some queris on .profile file Reply with quote

Adam Price wrote:

Quote:
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
Back to top
Adam Price
*nix forums beginner


Joined: 31 May 2005
Posts: 23

PostPosted: Thu Jun 15, 2006 7:55 pm    Post subject: Re: some queris on .profile file Reply with quote

On 15 Jun 2006 03:15:58 -0700, mehaboob@gmail.com wrote:

Quote:
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

Quote:

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.

Quote:
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.


Quote:
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.

Quote:
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.


Quote:
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
Back to top
Wim Cossement
*nix forums Guru Wannabe


Joined: 24 Feb 2005
Posts: 173

PostPosted: Thu Jun 15, 2006 12:37 pm    Post subject: Re: some queris on .profile file Reply with quote

mehaboob@gmail.com wrote:
Quote:
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.

Quote:
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.

Quote:
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

Quote:
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.

Quote:
6) #set -o emacs
Do we need this emacs setting?

If a line starts with the #, it's comment and thus ignored.

Quote:
Thanks in advance
Mehaboob


HTH,

Wimmy

--
Being owned by someone used to be called slavery.
Now it's called commitment.
Back to top
mehaboob@gmail.com
*nix forums beginner


Joined: 02 May 2006
Posts: 39

PostPosted: Thu Jun 15, 2006 10:15 am    Post subject: some queris on .profile file Reply with quote

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
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [14 Posts] View previous topic :: View next topic
The time now is Fri Nov 21, 2008 4:38 am | All times are GMT
navigation Forum index » *nix » Tru64
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Running php file everyday on scheduled time sachin PHP 1 Fri Jul 21, 2006 12:49 pm
No new posts Regarding thesaurus iso file Srikanth modules 0 Fri Jul 21, 2006 10:42 am
No new posts how can i get a file descriptor not used? mars system 0 Fri Jul 21, 2006 7:41 am
No new posts small GTK "Open file" dialog David Siroky Debian 0 Fri Jul 21, 2006 7:30 am
No new posts Trouble Declaring 3D Array in Header File free2klim C++ 1 Fri Jul 21, 2006 4:07 am

Credit Cards | Mortgages | Web Advertising | Bad Credit Mortgages | Personal Loans
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.5253s ][ Queries: 20 (0.2479s) ][ GZIP on - Debug on ]