- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: env variables on hpux 11i
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2006 09:26 AM
тАО02-01-2006 09:26 AM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2006 09:34 AM
тАО02-01-2006 09:34 AM
Re: env variables on hpux 11i
to verify:
set or export
to set permanently:
put them in the $HOME/.profile
export var=blah
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2006 09:36 AM
тАО02-01-2006 09:36 AM
Re: env variables on hpux 11i
system wide is done in /etc/profile
add the following line to set the set the default editor to vi
export EDITOR=vi
or the following lines do the same thing
set EDITOR=vi
export EDITOR
Tp set env variable for an individual user, add the lines in their .profile located in their home directory
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2006 09:36 AM
тАО02-01-2006 09:36 AM
SolutionAside from the standard environmental variables established during 'login' or a 'cron' tab initiation (see the manpages for both...) you have a couple of options.
You can set (and export) variables in your login profile.
You can create a standalone file that is sourced (read) by your login profile *and* any script that needs it.
In either case, you declare and export variables into your enviroment thusly:
# export MYPLACE=/var/tmp
# export MYID=`whoami`
If you put these examples into a file called "$HOME/mystuff" you would 'source' or read it thusly:
. $HOME/mystuff
Note that the operation of sourcing is to write a dot (".") followed by a space, followed by the filename to be read.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2006 09:37 AM
тАО02-01-2006 09:37 AM
Re: env variables on hpux 11i
export MYVAR1=this
export MYVAR2=that
Variables that are unique to a user are placed in .profile in the user's home directory. The .profile command are sourcec after those in /etc/profile so that it's possible to override those in /etc/profile.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2006 09:46 AM
тАО02-01-2006 09:46 AM
Re: env variables on hpux 11i
se you can verify your environment by using "env" command or individual variable by using echo $variable name) for exp-- echo $DISPLAY.
you can set these variable in the $HOME/.profile file.
thanks
karan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2006 09:48 AM
тАО02-01-2006 09:48 AM
Re: env variables on hpux 11i
U need to set Env variable in $HOME/.profile for each and every independent user.
e.g.
#vi /home/user1/.profile
export TERM=vt100
export PATH=$PATH:/usr/bin/ksh
export HISTSIZE=50
save and come out
#. /home/user1/.profile [enter]
Hope this will help u to resolve ur issue
Cheers
Indrajit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2006 10:49 AM
тАО02-01-2006 10:49 AM
Re: env variables on hpux 11i
Besides the standard environment script, any script can change environment variables.
Just set them like you would on the command line, export them and bingo, environment change.
to run them . scriptname
dot space scriptname.
Many of the applications running on an HP-9000 server require custom environment settings. Many of the Oracle applications you mentioned in your other posts required some environment customization.
So you'll be needing to do a lot of customization work on environments, if your post volume reflects the complexity of your actual servers.
I handle most of these issues when possible in the startup scripts. The users that own the various applications often require .profile or add in environment to properly manage their applications.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2006 12:44 PM
тАО02-01-2006 12:44 PM
Re: env variables on hpux 11i
If you add environmental variables to your user's profile's the temptation will be to source your profile in 'cron' jobs to have the variables passed into the environment.
This will lead to your cron jobs mailing their users messages complaining "not a typewriter". This occurs when terminal-oriented commands like 'stty' and 'tset' run in a terminal-less environment like a cron task.
While there are several ways to circumvent this, isolating your custom, environmental variables in their own file and (1) sourcing this file in your login profile; and (2) sourcing this file in any script that needs the variables; solves the problem.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2006 03:04 PM
тАО02-01-2006 03:04 PM
Re: env variables on hpux 11i
To set these variables permanently, you can modify these files,
/etc/profile
$HOME/.profile
# export $VARIABLE=New_Value
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2006 03:15 PM
тАО02-01-2006 03:15 PM
Re: env variables on hpux 11i
Some links about Shell variables which will help you to dig further
http://heather.cs.ucdavis.edu/~matloff/UnixAndC/Unix/ShellIntro.html
http://www.scit.wlv.ac.uk/~jphb/spos/notes/shell/shell1.html
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2006 03:25 PM
тАО02-01-2006 03:25 PM
Re: env variables on hpux 11i
The files you need to edit are
/etc/profile
$HOME/.profile
Any env command is used to verify the environment variables. Also you must know difference between set and env.
The set command shows all of the variables which have a value in the current shell instance. The env command shows all of the
current environment variables --- those variables which are inherited by (and visible to) newly created children
--
Prabu.S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2006 04:19 PM
тАО02-01-2006 04:19 PM
Re: env variables on hpux 11i
.
--
Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2006 04:22 PM
тАО02-01-2006 04:22 PM
Re: env variables on hpux 11i
you can declare variable as,
# export var="test"
# set var1="test"
# var2="test"
like that. Access scope of these will be differing in sub-shell.
--
Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2006 04:26 PM
тАО02-01-2006 04:26 PM
Re: env variables on hpux 11i
To know more about ENV, take a look at this,
http://docs.hp.com/en/B2355-90046/ch23s02.html?btnNext=next%A0%BB
[Shells: User's Guide > Chapter 23. Advanced Concepts and Commands -->The ENV Variable ]
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2006 05:19 PM
тАО02-01-2006 05:19 PM
Re: env variables on hpux 11i
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2006 05:23 PM
тАО02-01-2006 05:23 PM
Re: env variables on hpux 11i
JRF says, when you use custom varaibles in your profile, it will affect "cron" jobs running. To overcome this issue,
Isolating your custom, environmental variables in their own file and (1) sourcing this file in your login profile; and (2) sourcing this file in any script that needs the variables; solves the problem.
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2006 06:30 PM
тАО02-01-2006 06:30 PM
Re: env variables on hpux 11i
For e.g. if you would like to export two variable xyz and abc as follows:
# export XYZ=value1
# export ABC=value=2
Now instead of doing this directly into users profile we source the file which contains these variables. Like:
# vi file1
Add:
export XYZ=value1
export ABC=value=2
Save file:
Then you can do it as:
# source file1
Or add "source file1" into users profile.
This way you isolate these two variables from other environmental variables.
Hope that helps.
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2006 08:22 PM
тАО02-01-2006 08:22 PM
Re: env variables on hpux 11i
waht James writed in that you set some variabiles about terminal setting if you run your .profile inc rontab (no tty attached) you will receive an error.
To avoid this you can use:
if [[ $(tty) != "not a tty" ]] # tty attached
then
export bold=$(tput bold)
fi
HTH,
Art
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-01-2006 10:09 PM
тАО02-01-2006 10:09 PM
Re: env variables on hpux 11i
good day!
Also you can go through the manpage , when you get a chance :
# man sh-posix
Hope that will help to understand the environment variables.
Best Regards,
Raj.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-02-2006 02:04 AM
тАО02-02-2006 02:04 AM
Re: env variables on hpux 11i
You asked me to elaborate on my remarks about not adding environmental variables to login profiles.
First, understand that I am stating a *preference* of technique; *not dogma*.
The HP-UX Posix shell profile ('.profile') attempts to discern the characteristics of a terminal during login when the profile is processed. Part of the processing involves 'tset' and 'stty' commands. These functions expect STDIN to be associated with a terminal. If it isn't, as would be the case if you read your profile in a cron'ed script, then the message "Not a typewriter" is generated to STDERR.
Remember that any cron task that doesn't redirect STDOUT or STDERR will have that output mailed to the initiating user.
Now, consider what happens if you setup a cron task but source (read) your profile to gain your environmental variables for running it:
# . ./profile; ./somescript
[ The Forum may close-up the spaces above. That's a dot, a space, and then ".profile" ]
You propagated your environmental variables to your script just as you wanted, but you also got mail announcing "Not a typewriter" when your script ran.
There are several ways to eliminate this problem.
The first way around this annoyance is to redirect STDERR to /dev/null:
# . ./profile 2> /dev/null; ./somescript
There are two other solutions, too.
The first, is to modify your login profile to only execute its terminal-oriented commands when the process enviroment *is* terminal-based. Then, you are free to add environmental variables and source the profile as we first did.
To query the environment use [ -t 0 ] tests like:
if [ -t 0 ]; then
echo "I am terminal-based"
else
echo "I an NOT associated with a terminal"
fi
This ascertains whether STDIN (file descriptor 0) is associated with a terminal.
While I generally amend my login profiles with the [ -t 0 ] logic, I prefer to source a separate file of environmental variables. If I want these set during login, I source the file from the login profile. Otherwise, if I only need the variables in individual scripts, I source them within those scripts.
This is merely my preference, not dogma as I first stated. This is consistent with the Unix philosophy that there's more than one way to do anything!
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-02-2006 03:29 AM
тАО02-02-2006 03:29 AM