Operating System - HP-UX
1831294 Members
2922 Online
110022 Solutions
New Discussion

TERM - Environment Variable

 
Nikee Reddy
Regular Advisor

TERM - Environment Variable

Hello,

At present, we have 2 different kind of terminals, of which one of them support vt100 and the other support hpterm.

By default, when a admin user logon to the system, the TERM value is vt100.

venus:oracn2 > echo $TERM
vt100

What I have done is, I have created a file and inserted the following lines in it:

setenv TERM hpterm
clear

When I executed the file, the system is responding witht he following error message:

venus:oracn2 27> ./envterm
./envterm: setenv: not found.

But when I executed the follwoing command directly, it works fine:
setenv TERM hpterm
clear

What am I doing wrong in executing the file?

Thanks & regards,
Nikee


10 REPLIES 10
A. Clay Stephenson
Acclaimed Contributor

Re: TERM - Environment Variable

setenv is not a POSIX or Korn shell command but rather a csh command. I suspect that you shell is csh but when you execute your file, it's executing as a POSIX shell.
If it ain't broke, I can fix that.
Scott Palmer_1
Trusted Contributor

Re: TERM - Environment Variable

you should probably use the command
export TERM=hpterm

regards
Scott
Marvin Strong
Honored Contributor

Re: TERM - Environment Variable

setenv is part of csh

without a !#/usr/bin/csh line your script will run as posix, which does not understand setenv.
Marvin Strong
Honored Contributor

Re: TERM - Environment Variable

opps #!/usr/bin/csh

Sanjay_6
Honored Contributor

Re: TERM - Environment Variable

Hi,

Have you tried evaluating TERM in your profile.

-----
# Set up the terminal:
if [ "$TERM" = "" ]
then
eval ` tset -s -Q -m ':?hp' `
else
eval ` tset -s -Q `
fi
stty erase "^H" kill "^U" intr "^C" eof "^D"
stty hupcl ixon ixoff
tabs
-----

Hope this helps.

Regds
Nikee Reddy
Regular Advisor

Re: TERM - Environment Variable

Hello,

I have entered the following lines in the file:
#!/usr/bin/csh
setenv TERM hpterm
clear


I could able to execute the file with out any problems, but when I ran the following command I still see the same value for TERM i.e. vt100

venus:oracn2 24> echo $TERM
vt100

It shoud suppose to show me as hpterm instead as vt100 !!!!!!!!

Regards,
Nikee
Marvin Strong
Honored Contributor

Re: TERM - Environment Variable

Sorry, I didn't mean to mislead you, adding that will make your script run because it is now running in csh, but it will not solve your problem. Do to the nature of what #! does.

Your best course of action is to create a condition in your .profile that sets determines your TERM. As mentioned above.



KapilRaj
Honored Contributor

Re: TERM - Environment Variable

I think what youm should do it to keep script1.sh as follows,

#!/usr/bin/sh
export TERM=vt100
clear


And it should be executed as follows

/home/kaps>. script1 #Please note the "DOT" in front

Regds,

Kaps
Nothing is impossible
Peter Nikitka
Honored Contributor

Re: TERM - Environment Variable

Hi,

if you are running a csh / tcsh Shell, you must call

source script

to get the commands of script 'inline'
(not . script - this is for POSIX shells).
Otherwise the change of the environment
will not survive the newly created process...

If you want the changed value as a default,
put the commands in your ~/.chsrc

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"
Roberto Polli
Trusted Contributor

Re: TERM - Environment Variable

You all are right, but just to make it clear to the author:

1- when you run a script you have to specify the interpreter
2- all the environment settings made into a script will remain _into_ the script because it's run into another shell (which inherits some properties and envs of the father shell) invoked on the first line, and that shell will close automatically at the end of the script
3- to run a script in the current shell and not in another one you should
3a- write it using the current shell commands
3b- invoke it using the command "source" for [t]csh; or ". " note the blank after the dot, for "bourne shells" as sh/ksh/ash; latest bash supports both methods


After doing that, please, look at http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
it could be a starting point

Pax, R.