Languages and Scripting
Showing results for 
Search instead for 
Do you mean 

ksh(korn shell) - list of environment

Highlighted
Regular Advisor

ksh(korn shell) - list of environment

hello,

with the command "set" i can set serveral options like "set -x, set -a" and so on.
i have a difficult application and i want
to debug some steps. i want to know , which
options are used by "set". with command "env" , i can't see the settings. for example, in ORACLE-SQLPLUS , i can use the command "show all" and i can see the settings.

best regards

tom
7 REPLIES
Honored Contributor Honored Contributor

Re: ksh(korn shell) - list of environment

To get shell environement use like,

# env
# typeset
# set

read man ksh page.

--
Muthu
Easy to suggest when don't know about the problem!
Honored Contributor Honored Contributor

Re: ksh(korn shell) - list of environment

Hi,

Do a # man sh-posix and man ksh, you will find everything there.

_Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Honored Contributor Honored Contributor

Re: ksh(korn shell) - list of environment

Hi,

when you set environments in an application you can display them with
'echo $'
Put it in your program to check the current settings of the variable .

HTH
Volkmar
*** Say 'Thanks' with Kudos ***
Trusted Contributor Trusted Contributor

Re: ksh(korn shell) - list of environment

Hi tom,

just type "set" alone, it will display all currently set variables.

Addition stuff on shell programming in "Shells: User's Guide: HP 9000 Computers"
http://docs.hp.com/en/B2355-90046/

part III is for ksh.

antonio.
Honored Contributor Honored Contributor

Re: ksh(korn shell) - list of environment

Hi,

if you mean the value of options you have set with the set-command: Try
print $-
The variable '-' collect all the 'set'-flags, so:
set -x
set -e
print $-
ivx
(i -> interactive shell)

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
Honored Contributor Honored Contributor

Re: ksh(korn shell) - list of environment

There are two environments for POSIX shells, locally defined variables and exported variables. To see the local variable, just type:

set

To see the exported variable which will be passed onto a script or process, tpye the command:

env

Since set is for the local environment, things like set -x will not apply to a script that you run normally. To trace a script, you can eithee run it with the -x option as in:

sh -x ./myscript

or add set -x to the beginning of your script. Note that in a script, functions are like new scripts so they don't inherit the -x option, so you'll have to add it to your functions.

Note that all the flags for set options are found in the variable $- where if the option has been set, the letter appears and if not set, the letter is missing. So,

echo $-
inum

means set -i -n -u and -m are all set and all others are reset.
Regular Advisor

Re: ksh(korn shell) - list of environment

thank you for the helpful information's