Re: bash login script problems...

2002-06-19 Thread Colin Watson
On Wed, Jun 19, 2002 at 04:50:14PM +0200, Ivo Wever wrote:
> Derrick 'dman' Hudson wrote:
> >When you run a script in a subshell, it can modify the environment of
> >that subshell, then that subshell terminates (when the script is done)
> >and you get the prompt from your original shell again.  Unlike MS-DOS,
> >scripts normally run in subshells and can't wreak havoc on your
> >environment.  If you want to run the script in the current shell, use
> >one of the following commands :
> >. ./.bash_profile
> >source ./.bash_profile
> 
> Isn't this (changing $PATH from a script) what the 'export' command is
> for?

Unfortunately not. 'export' makes variables visible to subprocesses of a
script, but not to the parent process (in other words, the shell from
which you called that script).

-- 
Colin Watson  [EMAIL PROTECTED]


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: bash login script problems...

2002-06-19 Thread Ivo Wever

Derrick 'dman' Hudson wrote:

Neal Lippman wrote:
| I am having two problems with bash login scripts, which I cannot seem to sort 
| out. Probably something simple, but I'm missing it.
| 
| 1. First, here is a few lines from my .bash_profile. These lines were 
| commented out by default, and I have uncommented them. 

| I have verified, by adding some echo statements, that the body of the if 
| clause IS being executed when I issue './.bash_profile' and so my ~/bin dir 
^^^
> | should be getting added to my path. However, after the script completes, 
| 'echo $PATH' does NOT show any change to my path shell variable.
| 
| What am I missing here?


When you run a script in a subshell, it can modify the environment of
that subshell, then that subshell terminates (when the script is done)
and you get the prompt from your original shell again.  Unlike MS-DOS,
scripts normally run in subshells and can't wreak havoc on your
environment.  If you want to run the script in the current shell, use
one of the following commands :
. ./.bash_profile
source ./.bash_profile


Isn't this (changing $PATH from a script) what the 'export' command is for?
sincerely,
--
Ivo Wever
[EMAIL PROTECTED]


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]




Re: bash login script problems...

2002-06-15 Thread Neal Lippman

> When you run a script in a subshell, it can modify the environment of
> that subshell, then that subshell terminates (when the script is done)
> and you get the prompt from your original shell again.  Unlike MS-DOS,
> scripts normally run in subshells and can't wreak havoc on your
> environment.  If you want to run the script in the current shell, use
> one of the following commands :
> . ./.bash_profile
> source ./.bash_profile

Thanks. I was confusing the use of the export builtin and how it 
exports a 
shell variable to the environment.



>
> What I do is put all config stuff in ~/.bashrc and ~/.bash_profile
> looks like this :
>
>
> # .bash_profile
>
> if [ -f ~/.bashrc ]; then
> source ~/.bashrc
> fi

duh. Thanks very much.


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: bash login script problems...

2002-06-15 Thread Derrick 'dman' Hudson
On Sat, Jun 15, 2002 at 10:16:37PM -0400, Neal Lippman wrote:
| I am having two problems with bash login scripts, which I cannot seem to sort 
| out. Probably something simple, but I'm missing it.
| 
| 1. First, here is a few lines from my .bash_profile. These lines were 
| commented out by default, and I have uncommented them. 

| I have verified, by adding some echo statements, that the body of the if 
| clause IS being executed when I issue './.bash_profile' and so my ~/bin dir 
 ^^^

| should be getting added to my path. However, after the script completes, 
| 'echo $PATH' does NOT show any change to my path shell variable.
| 
| What am I missing here?

When you run a script in a subshell, it can modify the environment of
that subshell, then that subshell terminates (when the script is done)
and you get the prompt from your original shell again.  Unlike MS-DOS,
scripts normally run in subshells and can't wreak havoc on your
environment.  If you want to run the script in the current shell, use
one of the following commands :
. ./.bash_profile
source ./.bash_profile

| 2. I previously used Mandrake, and just switched to debian. Under KDE, when I 
| run a standard console shell (eg the standard KDE xterm), when I
| used mandrake it appeared that .bash_profile was automatically
| executed, and the suppled mandrake version then executed .bashrc for
| me. It appears that under Debian, however, .bashrc is executed
| directly and .bash_profile is only executed when I login directly on
| a ptty, rather than from an xterm under KDE.

This is normal.  Read 'man bash'.  ~/.bashrc is run for
non-login shells.  ~/.bash_profile is run for login shells.  When you
log in you start a login shell, when you run xterm you don't start a
login shell.

What I do is put all config stuff in ~/.bashrc and ~/.bash_profile
looks like this :


# .bash_profile

if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi

HTH,
-D

-- 

What good is it for a man to gain the whole world, yet forfeit his
soul?  Or what can a man give in exchange for his soul?
Mark 8:36-37
 
http://dman.ddts.net/~dman/



pgpJBIOA8Fv1M.pgp
Description: PGP signature


bash login script problems...

2002-06-15 Thread Neal Lippman
I am having two problems with bash login scripts, which I cannot seem to sort 
out. Probably something simple, but I'm missing it.

1. First, here is a few lines from my .bash_profile. These lines were 
commented out by default, and I have uncommented them. 

# set PATH so it includes user's private bin if it exists
# uncommented nl 6/15/02
if [ -d ~/bin ] ; then
PATH=~/bin:"${PATH}"
export PATH
fi

I have verified, by adding some echo statements, that the body of the if 
clause IS being executed when I issue './.bash_profile' and so my ~/bin dir 
should be getting added to my path. However, after the script completes, 
'echo $PATH' does NOT show any change to my path shell variable.

What am I missing here?

2. I previously used Mandrake, and just switched to debian. Under KDE, when I 
run a standard console shell (eg the standard KDE xterm), when I used 
mandrake it appeared that .bash_profile was automatically executed, and the 
suppled mandrake version then executed .bashrc for me. It appears that under 
Debian, however, .bashrc is executed directly and .bash_profile is only 
executed when I login directly on a ptty, rather than from an xterm under KDE.

Is my understanding correct? Is there any easy way to ensure that both 
scripts are executed regardless of the method of logging in and where I log 
in to (eg Mandrake or Debian)? The reason this matters, btw, is that my old 
Mandrake computer is now my file server, and the Debian system mounts my home 
directory as an NFS share, so logins to either system (and distro) now share 
the same files. As a result, when is SSH from teh debian system to the 
mandrake, I DON'T get my correct login scripts running, and I need a 
(relatively) simply way of having the same prompt format, aliases, etc 
regardless of whether I am workign on the Debian system or remotely on the 
(Mandrake) file server.

Thanks for any help.

Neal


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]