Re: some queris on .profile file




Bob Harris wrote:

In article
<1150576687.026459.179060@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
"mehaboob@xxxxxxxxx" <mehaboob@xxxxxxxxx> wrote:

Piotr Hosowicz wrote:

mehaboob@xxxxxxxxx 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

.



Relevant Pages

  • Re: Possible to define a variable for only certain directories?
    ... allows such customizations upon the environment on a per- ... this is useful only if the user or script ... configuration files, environment variables, command line options, and ... commands to the CDE Window Manager from a shell ...
    (comp.unix.shell)
  • Re: Environment variable not remembered outside a script?
    ... After executing the two files (.zshrc is already executed when I opened the ... This is a difference between running a script and sourcing it. ... and any environment variables it sets are ... themselves are not a shell feature but are actually part of the UNIX ...
    (comp.unix.shell)
  • Re: how perl set envirment variable
    ... You have just invoked a new copy of your shell ... environment changes you made in the Perl script. ... Jürgen Exner pointed out that Perl is often used in batch programming, ...
    (comp.lang.perl.misc)
  • Re: /etc/profile or $HOME/profile
    ... I created an user account and then changed ... You CAN NOT alter the environment of a another process. ... Try "source .profile" if the shell you are using supports it. ...
    (comp.unix.solaris)
  • Re: Where is su profile??
    ... My problem is, where is the profile ... I moved all of our admin scripts ... The environment includes the HOME environment ... 'su -' produces a shell that is considered a "login ...
    (comp.sys.hp.hpux)

Loading