pterm KSH environment variable inheritance mystery solved

I’m posting this at the prompting of another QNX user (It’s qrm’s fault)

I’ve had the most terrible time trying to understand where to put
environment variables such that when I run a pterm they show up. Especially
the PS1 variable.

Seems there are a few others that don’t understand either. Well…if this
is you, this is your lucky day.

First some basics:

  1. When you login, the following occurs (there may be more stuff, but this
    should be sufficient for this discussion.)
    a. The $HOME variable is set from your home dir entry in the passwd
    file (make sure this directory actually exists and that it is owned by you
    and at least one of the groups to which you belong).
    b. /etc/profile is run. This is a script MAKE SURE it has execute
    permissions.
    c. $HOME/.profile script is run…make sure this also has execute
    permissions (these two have been problems for me and others)
    d. A shell is started.
    e. Before the shell gives you a prompt, it looks for the environment
    var ‘ENV’, if set with a proper file name, will try to execute the file as a
    script.

  2. One thing occurs when /etc/profile is run that is interesting. There is
    a bit of code in there that attempts to set the $ENV variable.
    This is set if the name used to start your shell (with a ‘.’ in front)
    exists as a script (with execute permissions) in your home directory. So,
    if you use ksh and it was started using sh, and you are ‘root’, and you have
    created a /root/.sh file (with execute permissions) ENV will be set to
    ‘/root/.sh’. Thus when a shell is invoked, that script will be run.
    This is important because there are some environment variables that get
    overridden when the shell starts (i.e. PS1), so in order to get these, you
    need to have a ‘.sh’ file that will set it for you. It isn’t good enough
    for them to be in the $HOME/.profile script.

Now, what does this have to do with pterm?

Well…funny you should ask.

If you use the graphical login, it will run /etc/profile and
$HOME/.profile…you just won’t see it. Therefore it is important that if
you want to set a environment variable like ‘PS1’, you will need to create a
…sh file (or .bash if you are using bash (I think, I don’t use bash, so I
can’t say)) in your home directory and give it execute permissions. Put the
required ‘export PS1=blah blah blah’ in .sh.

Then when you start a pterm, the ‘.sh’ file will be executed and any
shifting environment variables can be set.

Note that there are many environment variables that will be inherited by the
shell from the execution of /etc/profile and $HOME/.profile (when you logged
into photon), so you don’t need to load ‘.sh’ with redundant stuff…


Hope this was useful. (no complaining about the bad grammar, I was in a
hurry!),

Kevin

It is good to get these things clarified. Steve Reed are you paying
attention.

What is the effect of the /etc/default/login file?

“Kevin Stallard” <kevin@ffflyingrobots.com> wrote in message
news:a8vslc$dk9$1@inn.qnx.com

I’m posting this at the prompting of another QNX user (It’s qrm’s fault)

I’ve had the most terrible time trying to understand where to put
environment variables such that when I run a pterm they show up.
Especially
the PS1 variable.

Seems there are a few others that don’t understand either. Well…if this
is you, this is your lucky day.

First some basics:

  1. When you login, the following occurs (there may be more stuff, but
    this
    should be sufficient for this discussion.)
    a. The $HOME variable is set from your home dir entry in the passwd
    file (make sure this directory actually exists and that it is owned by you
    and at least one of the groups to which you belong).
    b. /etc/profile is run. This is a script MAKE SURE it has execute
    permissions.
    c. $HOME/.profile script is run…make sure this also has execute
    permissions (these two have been problems for me and others)
    d. A shell is started.
    e. Before the shell gives you a prompt, it looks for the environment
    var ‘ENV’, if set with a proper file name, will try to execute the file as
    a
    script.

  2. One thing occurs when /etc/profile is run that is interesting. There
    is
    a bit of code in there that attempts to set the $ENV variable.
    This is set if the name used to start your shell (with a ‘.’ in front)
    exists as a script (with execute permissions) in your home directory. So,
    if you use ksh and it was started using sh, and you are ‘root’, and you
    have
    created a /root/.sh file (with execute permissions) ENV will be set to
    ‘/root/.sh’. Thus when a shell is invoked, that script will be run.
    This is important because there are some environment variables that
    get
    overridden when the shell starts (i.e. PS1), so in order to get these, you
    need to have a ‘.sh’ file that will set it for you. It isn’t good enough
    for them to be in the $HOME/.profile script.

Now, what does this have to do with pterm?

Well…funny you should ask.

If you use the graphical login, it will run /etc/profile and
$HOME/.profile…you just won’t see it. Therefore it is important that
if
you want to set a environment variable like ‘PS1’, you will need to create
a
.sh file (or .bash if you are using bash (I think, I don’t use bash, so I
can’t say)) in your home directory and give it execute permissions. Put
the
required ‘export PS1=blah blah blah’ in .sh.

Then when you start a pterm, the ‘.sh’ file will be executed and any
shifting environment variables can be set.

Note that there are many environment variables that will be inherited by
the
shell from the execution of /etc/profile and $HOME/.profile (when you
logged
into photon), so you don’t need to load ‘.sh’ with redundant stuff…


Hope this was useful. (no complaining about the bad grammar, I was in a
hurry!),

Kevin
\

Kevin Stallard <kevin@ffflyingrobots.com> wrote:
: I’m posting this at the prompting of another QNX user (It’s qrm’s fault)

: I’ve had the most terrible time trying to understand where to put
: environment variables such that when I run a pterm they show up. Especially
: the PS1 variable.

I’ll forward this to the writer who’s in charge of the Sys Admin guide
and Utilities Reference. On a related topic, the docs for 6.2 have a
technote about how PATH and LD_LIBRARY_PATH get set.

Thanks for posting your notes.


Steve Reid stever@qnx.com
TechPubs (Technical Publications)
QNX Software Systems

“Bill Caroselli (Q-TPS)” <QTPS@earthlink.net> wrote:
: It is good to get these things clarified. Steve Reed are you paying
: attention.
:
: What is the effect of the /etc/default/login file?

Here’s what the docs for login state:

The login utility also sets the environment variables specified in the
/etc/default/login file. This file lets you specify which
environment variable settings are to be used across login sessions. If
a variable isn’t set when login is started and this file contains a
default for the variable, that default is used. If the file doesn’t contain a
default for the variable, the variable is cleared by login. If a variable is
already set when login is started and -p is specified, it’s preserved,
even if the /etc/default/login file contains a default for the
variable. The -p option allows site-specific environment variables to
be passed from the system startup processes down to applications.


Steve Reid stever@qnx.com
TechPubs (Technical Publications)
QNX Software Systems

A few comments if you don’t mind…

You can find a lot about how a POSIX shell should work in the
latest POSIX/Open Group specs:

http://www.opengroup.org/onlinepubs/007904975/utilities/sh.html

There’s a good chance that our shell is not a perfect implementation
of what the standard requires – please report any bugs you
discover. There also are things that POSIX doesn’t cover – for
instance, I don’t think POSIX cares that the shell gets some of its
initial settings from an external file called /etc/profile.


Kevin Stallard <kevin@ffflyingrobots.com> wrote:

I’m posting this at the prompting of another QNX user (It’s qrm’s fault)

I’ve had the most terrible time trying to understand where to put
environment variables such that when I run a pterm they show up. Especially
the PS1 variable.

Seems there are a few others that don’t understand either. Well…if this
is you, this is your lucky day.

First some basics:

  1. When you login, the following occurs (there may be more stuff, but this
    should be sufficient for this discussion.)
    a. The $HOME variable is set from your home dir entry in the passwd
    file (make sure this directory actually exists and that it is owned by you
    and at least one of the groups to which you belong).

At this point, login execs into the shell.

Login sets the shell’s arguments so that argv[0] starts with a ‘-’
– that’s how shells traditionally recognize that they’re running as
a “login shell” and should run things like /etc/profile and
.profile. (The reason I’m mentioning this is because this also is
what pterm’s -l option does.)

b. /etc/profile is run. This is a script MAKE SURE it has execute
permissions.

/etc/profile is executed by your shell as a dot script. AFAIK, it
doesn’t need to have the execute permission (it doesn’t have it on
my machine).

c. $HOME/.profile script is run…make sure this also has execute
permissions (these two have been problems for me and others)

This one is also executed as a dot script. I’ve never needed to set
its execute permission, either.

d. A shell is started.

It’s started before step b.

e. Before the shell gives you a prompt, it looks for the environment
var ‘ENV’, if set with a proper file name, will try to execute the file as a
script.

Again, as a “dot script” (i.e. it does not spawn another shell,
which is done for regular scripts).

  1. One thing occurs when /etc/profile is run that is interesting. There is
    a bit of code in there that attempts to set the $ENV variable.

You don’t need to care about this if your .profile overwrites ENV
with a new value. Mine does, and I had no idea that /etc/profile
tries to do that until a few days ago…

This is set if the name used to start your shell (with a ‘.’ in front)
exists as a script (with execute permissions) in your home directory. So,
if you use ksh and it was started using sh, and you are ‘root’, and you have
created a /root/.sh file (with execute permissions) ENV will be set to
‘/root/.sh’. Thus when a shell is invoked, that script will be run.

Unless your .profile changes it to run some other script instead.

This is important because there are some environment variables that get
overridden when the shell starts (i.e. PS1), so in order to get these, you
need to have a ‘.sh’ file that will set it for you. It isn’t good enough
for them to be in the $HOME/.profile script.

Hm… It seems to be good enough for me.

Now, what does this have to do with pterm?

Well…funny you should ask.

If you use the graphical login, it will run /etc/profile and
$HOME/.profile…you just won’t see it. Therefore it is important that if
you want to set a environment variable like ‘PS1’, you will need to create a
.sh file (or .bash if you are using bash (I think, I don’t use bash, so I

I don’t use bash either, but I vaguely remember that people had some
problems with phlogin when their default shell was bash. But that
was really long ago (under QNX4) and hopefully is fixed now.

can’t say)) in your home directory and give it execute permissions. Put the
required ‘export PS1=blah blah blah’ in .sh.

Like I said, defining PS1 in my .profile works for me.

Instead of relying on the code in /etc/profile that tries to find
your ~/.sh, I prefer to set ENV by hand in my .profile. This not
only lets me pick a name other than .sh for my file – it also seems
more portable (it even works under QNX4…).

Then when you start a pterm, the ‘.sh’ file will be executed and any
shifting environment variables can be set.

Note that there are many environment variables that will be inherited by the
shell from the execution of /etc/profile and $HOME/.profile (when you logged
into photon), so you don’t need to load ‘.sh’ with redundant stuff…

Are you suggesting that there are environment variables that are
not inherited and you have to set them in your $ENV file instead
of your .profile?

Like I said, setting environment variables in my .profile works for
me. I use the $ENV file for things that aren’t inherited, like
shell functions and aliases.

There’s one more thing worth mentioning: with our shell, the $ENV file
is executed by every shell you start, including non-interactive shells
that run your scripts or are spawned when your code calls system(). If
your $ENV file defines shell functions or aliases that change the
meaning of system commands (like alias rm=“rm -i”), this could break
some shell scripts or programs that expect the usual behaviour of those
commands. Also, if your $ENV file runs external programs, this could
significantly slow down programs that spawn a lot of shells (like make).

It’s wise to put code in your $ENV file to detect whether the shell that
executes it is interactive, and do as little as possible if it’s not.
As a side effect, this will make your environment more compatible with
future shells – the new Open Group specs say that $ENV should not be
looked at by a non-interactive shell, even though the previous version
of the specs did not make this distinction.

You can detect whether the shell is interactive by looking at the $-
variable. In an interactive shell, it will contain an ‘i’. For
instance, this is what I have in my $ENV file:

case “$-” in
i)

Do all the slow or dangerous stuff here

esac


Wojtek Lerch QNX Software Systems Ltd.

Kevin Stallard <kevin@ffflyingrobots.com> wrote:

I’m posting this at the prompting of another QNX user (It’s qrm’s fault)

I followed up to this in comp.os.qnx.

Apparently its here too. Here’s a copy of my followup from comp.os.qnx.

-David

Kevin Stallard <kevin@ffflyingrobots.com> wrote:

I’m posting this at the prompting of another QNX user (It’s qrm’s fault)

I’ve had the most terrible time trying to understand where to put
environment variables such that when I run a pterm they show up. Especially
the PS1 variable.

Seems there are a few others that don’t understand either. Well…if this
is you, this is your lucky day.

First some basics:

  1. When you login, the following occurs (there may be more stuff, but this
    should be sufficient for this discussion.)
    a. The $HOME variable is set from your home dir entry in the passwd
    file (make sure this directory actually exists and that it is owned by you
    and at least one of the groups to which you belong).
    b. /etc/profile is run. This is a script MAKE SURE it has execute
    permissions.
    c. $HOME/.profile script is run…make sure this also has execute
    permissions (these two have been problems for me and others)
    d. A shell is started.

NOPE. Wrong order here.

login sets the $HOME environment variable.

It then runs a shell with argv[0][0]=’-’

try a “sin arg”, you will see something like:
563 dagibbs -sh

The shell then does its initialization.

Shell initialization rules:

if argv[0][0] is ‘-’ then this is a “login shell”
{
– include & evaluate the shell commands in /etc/profile (if it exists)
– include & evaluate the shell commands in $HOME/.pofile (if it exists)
}
check for the ENV environment variable, if it is set:
– include & evaluate the shell commands in $ENV (if it exists)

Traditionally the file ENV points to is $HOME/.rc, e.g.
/home/dagibbs/.kshrc or /home/dagibbs/.shrc

Note: environment variables are inheritted from parent to child, but
aliases and shell functions are not. So, generally, you should export
environment variables in your .profile, but set aliases or declare shell
functions you want to use in your .shrc (ENV target) file.

e. Before the shell gives you a prompt, it looks for the environment
var ‘ENV’, if set with a proper file name, will try to execute the file as a
script.



Now, what does this have to do with pterm?

Well…funny you should ask.

If you run “pterm -l” it will start your shells as a “login shell” and
you will get all the normal startup that you expect.

This is generally the easiest and cleanest way of getting a consistent
environment in your pterm shells, and the one I use.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

I also replied to David’s post as I think the one thing not mentioned by
David that is important is that I believe phlogin executes /etc/profile and
$HOME/.profile before pterm is even started. See below:

snip

First some basics:

  1. When you login, the following occurs (there may be more stuff, but
    this
    should be sufficient for this discussion.)
    a. The $HOME variable is set from your home dir entry in the passwd
    file (make sure this directory actually exists and that it is owned by
    you
    and at least one of the groups to which you belong).
    b. /etc/profile is run. This is a script MAKE SURE it has execute
    permissions.
    c. $HOME/.profile script is run…make sure this also has execute
    permissions (these two have been problems for me and others)
    d. A shell is started.

NOPE. Wrong order here.

login sets the $HOME environment variable.

I’m sure it does, but it uses the entry in your passwd file. So I’m
technically still correct. (phlogin also sets this)

It then runs a shell with argv[0][0]=’-’

try a “sin arg”, you will see something like:
563 dagibbs -sh

The shell then does its initialization.

Shell initialization rules:

if argv[0][0] is ‘-’ then this is a “login shell”
{
– include & evaluate the shell commands in /etc/profile (if it
exists)
– include & evaluate the shell commands in $HOME/.pofile (if it
exists)
}
check for the ENV environment variable, if it is set:
– include & evaluate the shell commands in $ENV (if it exists)

Traditionally the file ENV points to is $HOME/.rc, e.g.
/home/dagibbs/.kshrc or /home/dagibbs/.shrc

The /etc/profile file sets ENV. (At least under QNX 6) The following lines
can be
found there:
if test -z “$ENV”; then;
ENV=~/.$(SHELL##*/}
if test -x $ENV; then
export ENV
else
unset ENV
fi
fi

Like I said, under QNX 6.x, this $ENV will be .sh and not .kshrc or
…shrc like it was in QNX 4.2x
(If the shell you are running is ‘sh’)


Note: environment variables are inheritted from parent to child, but
aliases and shell functions are not. So, generally, you should export
environment variables in your .profile, but set aliases or declare shell
functions you want to use in your .shrc (ENV target) file.

e. Before the shell gives you a prompt, it looks for the
environment
var ‘ENV’, if set with a proper file name, will try to execute the file
as a
script.


Now, what does this have to do with pterm?

Well…funny you should ask.

If you run “pterm -l” it will start your shells as a “login shell” and
you will get all the normal startup that you expect.

This is generally the easiest and cleanest way of getting a consistent
environment in your pterm shells, and the one I use.

However you neglect to see that /etc/profile and $HOME/.profile are run by
phlogin, thus setting ENV variables that can be inherited before any pterm
is run. Thus you don’t have to go and change any refrences to the laucning
of pterm and add a -l to the invocation.

This was my whole point. It all will work as it comes w/o invocting pterm
with the -l.

If you don’t belive me, do the following:
Remove any pterm invoking with the -l (i.e. from the shelf)
Insure your $HOME/.profile has some crazy env variable that it sets.
I.E. export SCOOBY=12345
Logoff photon
At the graphical photon login screen…login (don’t just type ph from
your text login in other words)
Open a pterm
type: echo $SCOOBY

If .profile is in the correct place and has exceute premissions, you
will see
12345

All w/o adding the -l to pterm.

The reason I’m so insistant with this is that I thought that the -l would
necessary as well, but I want to point out that the default settings do
work and no change to them is necessary (i.e. modifying the pterm shelf
item and adding -l after you install QNX 6.x).

Kevin

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

Just like the post in comp.os.qnx, my ego is breaking forth and therefore a
nice conversational tone is not being set forth in my postings.

I don’t mean to pick on you David, I hope I haven’t offended you.

Kevin

“Kevin Stallard” <kevin@ffflyingrobots.com> wrote in message
news:a91m5j$o7i$1@inn.qnx.com

I also replied to David’s post as I think the one thing not mentioned by
David that is important is that I believe phlogin executes /etc/profile
and
$HOME/.profile before pterm is even started. See below:

snip

First some basics:

  1. When you login, the following occurs (there may be more stuff, but
    this
    should be sufficient for this discussion.)
    a. The $HOME variable is set from your home dir entry in the
    passwd
    file (make sure this directory actually exists and that it is owned by
    you
    and at least one of the groups to which you belong).
    b. /etc/profile is run. This is a script MAKE SURE it has
    execute
    permissions.
    c. $HOME/.profile script is run…make sure this also has execute
    permissions (these two have been problems for me and others)
    d. A shell is started.

NOPE. Wrong order here.

login sets the $HOME environment variable.

I’m sure it does, but it uses the entry in your passwd file. So I’m
technically still correct. (phlogin also sets this)


It then runs a shell with argv[0][0]=’-’

try a “sin arg”, you will see something like:
563 dagibbs -sh

The shell then does its initialization.

Shell initialization rules:

if argv[0][0] is ‘-’ then this is a “login shell”
{
– include & evaluate the shell commands in /etc/profile (if it
exists)
– include & evaluate the shell commands in $HOME/.pofile (if it
exists)
}
check for the ENV environment variable, if it is set:
– include & evaluate the shell commands in $ENV (if it exists)

Traditionally the file ENV points to is $HOME/.rc, e.g.
/home/dagibbs/.kshrc or /home/dagibbs/.shrc

The /etc/profile file sets ENV. (At least under QNX 6) The following
lines
can be
found there:
if test -z “$ENV”; then;
ENV=~/.$(SHELL##*/}
if test -x $ENV; then
export ENV
else
unset ENV
fi
fi

Like I said, under QNX 6.x, this $ENV will be .sh and not .kshrc or
.shrc like it was in QNX 4.2x
(If the shell you are running is ‘sh’)



Note: environment variables are inheritted from parent to child, but
aliases and shell functions are not. So, generally, you should export
environment variables in your .profile, but set aliases or declare shell
functions you want to use in your .shrc (ENV target) file.

e. Before the shell gives you a prompt, it looks for the
environment
var ‘ENV’, if set with a proper file name, will try to execute the
file
as a
script.


Now, what does this have to do with pterm?

Well…funny you should ask.

If you run “pterm -l” it will start your shells as a “login shell” and
you will get all the normal startup that you expect.

This is generally the easiest and cleanest way of getting a consistent
environment in your pterm shells, and the one I use.

However you neglect to see that /etc/profile and $HOME/.profile are run
by
phlogin, thus setting ENV variables that can be inherited before any
pterm
is run. Thus you don’t have to go and change any refrences to the
laucning
of pterm and add a -l to the invocation.

This was my whole point. It all will work as it comes w/o invocting pterm
with the -l.

If you don’t belive me, do the following:
Remove any pterm invoking with the -l (i.e. from the shelf)
Insure your $HOME/.profile has some crazy env variable that it sets.
I.E. export SCOOBY=12345
Logoff photon
At the graphical photon login screen…login (don’t just type ph from
your text login in other words)
Open a pterm
type: echo $SCOOBY

If .profile is in the correct place and has exceute premissions, you
will see
12345

All w/o adding the -l to pterm.

The reason I’m so insistant with this is that I thought that the -l would
necessary as well, but I want to point out that the default settings do
work and no change to them is necessary (i.e. modifying the pterm shelf
item and adding -l after you install QNX 6.x).

Kevin


-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.
\

OK. I get it.

So If I’m already logged in and I set some goofy environment variable, let’s
say for terminal handling, and then I go to log in as someone else, my
special variable will be lost (as I’ve noticed) but not if I put it in
/etc/default/login AND use ‘login -p’. Cool! I’ve wanted to do that for
years.

“Steve Reid” <stever@qnx.com> wrote in message
news:a91eqd$c0q$2@nntp.qnx.com

“Bill Caroselli (Q-TPS)” <> QTPS@earthlink.net> > wrote:
: It is good to get these things clarified. Steve Reed are you paying
: attention.
:
: What is the effect of the /etc/default/login file?

Here’s what the docs for login state:

The login utility also sets the environment variables specified in the
/etc/default/login file. This file lets you specify which
environment variable settings are to be used across login sessions. If
a variable isn’t set when login is started and this file contains a
default for the variable, that default is used. If the file doesn’t
contain a
default for the variable, the variable is cleared by login. If a
variable is
already set when login is started and -p is specified, it’s preserved,
even if the /etc/default/login file contains a default for the
variable. The -p option allows site-specific environment variables to
be passed from the system startup processes down to applications.


Steve Reid > stever@qnx.com
TechPubs (Technical Publications)
QNX Software Systems

Thanks. This is VERY helpful.

“Wojtek Lerch” <wojtek_l@yahoo.ca> wrote in message
news:a91iui$fhf$1@nntp.qnx.com

You can detect whether the shell is interactive by looking at the $-
variable. In an interactive shell, it will contain an ‘i’. For
instance, this is what I have in my $ENV file:

case “$-” in
i)

Do all the slow or dangerous stuff here

esac

If you put a sleep 30 in /etc/profile (or $HOME/.profile) and then login
using phlogin (into photon) you will see a 30 second delay.

In case you really wanted to know but were too afraid to ask…:slight_smile:

Kevin

“Kevin Stallard” <kevin@ffflyingrobots.com> wrote in message
news:a91m5j$o7i$1@inn.qnx.com

I also replied to David’s post as I think the one thing not mentioned by
David that is important is that I believe phlogin executes /etc/profile
and
$HOME/.profile before pterm is even started. See below:

snip

First some basics:

  1. When you login, the following occurs (there may be more stuff, but
    this
    should be sufficient for this discussion.)
    a. The $HOME variable is set from your home dir entry in the
    passwd
    file (make sure this directory actually exists and that it is owned by
    you
    and at least one of the groups to which you belong).
    b. /etc/profile is run. This is a script MAKE SURE it has
    execute
    permissions.
    c. $HOME/.profile script is run…make sure this also has execute
    permissions (these two have been problems for me and others)
    d. A shell is started.

NOPE. Wrong order here.

login sets the $HOME environment variable.

I’m sure it does, but it uses the entry in your passwd file. So I’m
technically still correct. (phlogin also sets this)


It then runs a shell with argv[0][0]=’-’

try a “sin arg”, you will see something like:
563 dagibbs -sh

The shell then does its initialization.

Shell initialization rules:

if argv[0][0] is ‘-’ then this is a “login shell”
{
– include & evaluate the shell commands in /etc/profile (if it
exists)
– include & evaluate the shell commands in $HOME/.pofile (if it
exists)
}
check for the ENV environment variable, if it is set:
– include & evaluate the shell commands in $ENV (if it exists)

Traditionally the file ENV points to is $HOME/.rc, e.g.
/home/dagibbs/.kshrc or /home/dagibbs/.shrc

The /etc/profile file sets ENV. (At least under QNX 6) The following
lines
can be
found there:
if test -z “$ENV”; then;
ENV=~/.$(SHELL##*/}
if test -x $ENV; then
export ENV
else
unset ENV
fi
fi

Like I said, under QNX 6.x, this $ENV will be .sh and not .kshrc or
.shrc like it was in QNX 4.2x
(If the shell you are running is ‘sh’)



Note: environment variables are inheritted from parent to child, but
aliases and shell functions are not. So, generally, you should export
environment variables in your .profile, but set aliases or declare shell
functions you want to use in your .shrc (ENV target) file.

e. Before the shell gives you a prompt, it looks for the
environment
var ‘ENV’, if set with a proper file name, will try to execute the
file
as a
script.


Now, what does this have to do with pterm?

Well…funny you should ask.

If you run “pterm -l” it will start your shells as a “login shell” and
you will get all the normal startup that you expect.

This is generally the easiest and cleanest way of getting a consistent
environment in your pterm shells, and the one I use.

However you neglect to see that /etc/profile and $HOME/.profile are run
by
phlogin, thus setting ENV variables that can be inherited before any
pterm
is run. Thus you don’t have to go and change any refrences to the
laucning
of pterm and add a -l to the invocation.

This was my whole point. It all will work as it comes w/o invocting pterm
with the -l.

If you don’t belive me, do the following:
Remove any pterm invoking with the -l (i.e. from the shelf)
Insure your $HOME/.profile has some crazy env variable that it sets.
I.E. export SCOOBY=12345
Logoff photon
At the graphical photon login screen…login (don’t just type ph from
your text login in other words)
Open a pterm
type: echo $SCOOBY

If .profile is in the correct place and has exceute premissions, you
will see
12345

All w/o adding the -l to pterm.

The reason I’m so insistant with this is that I thought that the -l would
necessary as well, but I want to point out that the default settings do
work and no change to them is necessary (i.e. modifying the pterm shelf
item and adding -l after you install QNX 6.x).

Kevin


-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.
\

Kevin Stallard <kevin@ffflyingrobots.com> wrote:

If you put a sleep 30 in /etc/profile (or $HOME/.profile) and then login
using phlogin (into photon) you will see a 30 second delay.

Yup. Phlogin execs into a shell to run the ph script, and does the
argv[0][0] == ‘-’ trick to make the shell run /etc/profile and your
~/.profile first.

BTW I think the problem with bash was that if it was given a script to
run, it wasn’t paying attention to argv[0][0]. Or something like that.


Wojtek Lerch QNX Software Systems Ltd.

Kevin Stallard <kevin@ffflyingrobots.com> wrote:

I also replied to David’s post as I think the one thing not mentioned by
David that is important is that I believe phlogin executes /etc/profile and
$HOME/.profile before pterm is even started. See below:

And, as I said over there, phlogin does not look at /etc/profile or
$HOME/.profile – it starts a shell and the shell parses them.
Just like login does.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

“Bill Caroselli (Q-TPS)” <QTPS@earthlink.net> wrote:

OK. I get it.

So If I’m already logged in and I set some goofy environment variable, let’s
say for terminal handling, and then I go to log in as someone else, my
special variable will be lost (as I’ve noticed) but not if I put it in
/etc/default/login AND use ‘login -p’. Cool! I’ve wanted to do that for
years.

Close.

Change the AND to an OR and you’ve got it right.

The env variable will be preserved if you use “login -p” OR if the
variable is listed in /etc/default/login.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

Kevin Stallard <kevin@ffflyingrobots.com> wrote:

Just like the post in comp.os.qnx, my ego is breaking forth and therefore a
nice conversational tone is not being set forth in my postings.

I don’t mean to pick on you David, I hope I haven’t offended you.

No offense taken.

BTW, people…if you sometimes wonder why we ask people to NOT
cross-post articles.

Well, try following both threads of this discussion, looking at
what there has been as far as duplicated information or responses
that would have been better if all together.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

Ok, that makes sense…thanks

Kevin

“David Gibbs” <dagibbs@qnx.com> wrote in message
news:a928q1$1a2$2@nntp.qnx.com

Kevin Stallard <> kevin@ffflyingrobots.com> > wrote:
I also replied to David’s post as I think the one thing not mentioned by
David that is important is that I believe phlogin executes /etc/profile
and
$HOME/.profile before pterm is even started. See below:

And, as I said over there, phlogin does not look at /etc/profile or
$HOME/.profile – it starts a shell and the shell parses them.
Just like login does.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

Yes, I see what you mean, however, I know that I frequent qdn.public.qnxrtp
much more than anyother, and thought it important enough that it be in both
(figured there would be others like me). Now I see the error in my
thinking, next time it may be more appropriate to put a short blurb in one
that points to the more meatier version in the other (some of this at the
time also applied, I thought, to qnx4).

Ok, ok, so I’m justifiing a little, we all to that, right? :slight_smile:

Kevin



“David Gibbs” <dagibbs@qnx.com> wrote in message
news:a92953$1a2$4@nntp.qnx.com

Kevin Stallard <> kevin@ffflyingrobots.com> > wrote:
Just like the post in comp.os.qnx, my ego is breaking forth and
therefore a
nice conversational tone is not being set forth in my postings.

I don’t mean to pick on you David, I hope I haven’t offended you.

No offense taken.

BTW, people…if you sometimes wonder why we ask people to NOT
cross-post articles.

Well, try following both threads of this discussion, looking at
what there has been as far as duplicated information or responses
that would have been better if all together.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

Hi Kevin

Like many of you, I read (scan actually) every message in all of the QDN
newsgroups. Most people complain because they just don’t like reading the
same message more than once. I don’t blame them, so do I. But I am more
annoyed when you see a message that is splattered across 8 different
newsgroups. But on the other hand I can usually read the first few words
and recognize that I’ve seen this before and hit ‘U’. (Of course I also do
this is the subject just isn’t interesting to me.)

Sometimes you have a question and your just not sure if it is a Photon
question or an OS question (or whatever). Personally I would continue to
ask if two different newsgroups, if I felt it was necessary.

It does get confusing when a thread like this one is being carried on in two
different newsgroups. Usually, one newsgroup will grab the thread and run
with it and the other one will die quietly.

Here is my recommendation. If necessary, ask in two different groups,
mention that you asked in these two group and suggest that the replies all
be made in one of the newsgroups.


“Kevin Stallard” <kevin@ffflyingrobots.com> wrote in message
news:a94bt0$o8r$1@inn.qnx.com

Yes, I see what you mean, however, I know that I frequent
qdn.public.qnxrtp
much more than anyother, and thought it important enough that it be in
both
(figured there would be others like me). Now I see the error in my
thinking, next time it may be more appropriate to put a short blurb in one
that points to the more meatier version in the other (some of this at the
time also applied, I thought, to qnx4).

Ok, ok, so I’m justifiing a little, we all to that, right? > :slight_smile:

Kevin



“David Gibbs” <> dagibbs@qnx.com> > wrote in message
news:a92953$1a2$> 4@nntp.qnx.com> …
Kevin Stallard <> kevin@ffflyingrobots.com> > wrote:
Just like the post in comp.os.qnx, my ego is breaking forth and
therefore a
nice conversational tone is not being set forth in my postings.

I don’t mean to pick on you David, I hope I haven’t offended you.

No offense taken.

BTW, people…if you sometimes wonder why we ask people to NOT
cross-post articles.

Well, try following both threads of this discussion, looking at
what there has been as far as duplicated information or responses
that would have been better if all together.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.