Can't set environment variable on OpenBSD 3.8

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Can't set environment variable on OpenBSD 3.8

Tomas-7
Hello,



I cant set environment variable on OpenBSD 3.8. I issue command env
testvar=var and I get printout with all the environment variables:

PS1=#

PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/local/bin

SHELL=/bin/ksh

USER=root

LESS=-NWi

MAIL=/var/mail/tomas

HOME=/root

SSH_CLIENT=10.30.1.15 3578 22

LESSOPEN=|~/lesspipe.sh %s

SUDO_USER=tomas

SUDO_GID=1000

TERM=xterm

SUDO_COMMAND=/usr/bin/su

SUDO_UID=1000

SSH_TTY=/dev/ttyp0

PAGER=less

LOGNAME=root

testvar=var



And after that I issue command env and I get printout without my testvar:

PS1=#

PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/local/bin

SHELL=/bin/ksh

USER=root

LESS=-NWi

MAIL=/var/mail/tomas

HOME=/root

SSH_CLIENT=10.30.1.15 3578 22

LESSOPEN=|~/lesspipe.sh %s

SUDO_USER=tomas

SUDO_GID=1000

TERM=xterm

SUDO_COMMAND=/usr/bin/su

SUDO_UID=1000

SSH_TTY=/dev/ttyp0

PAGER=less

LOGNAME=root

What could I be doing wrong?

Reply | Threaded
Open this post in threaded view
|

Re: Can't set environment variable on OpenBSD 3.8

Fergus Wilde
On Tuesday 08 November 2005 07:17, Tomas wrote:
> Hello,
>
>
>
> I cant set environment variable on OpenBSD 3.8. I issue command env
> testvar=var and I get printout with all the environment variables:

<and so on>

I seem to be having no difficulty setting $TESTVAR on 3.8 here using these
commands; in csh:

# setenv TESTVAR var

# echo $TESTVAR
var

in ksh:

export TESTVAR=var

# echo $TESTVAR
var

Sorry if I have misunderstood the question.

HTH
Fergus

Reply | Threaded
Open this post in threaded view
|

Re: Can't set environment variable on OpenBSD 3.8

knitti
In reply to this post by Tomas-7
try using "export testvar=var".

Reply | Threaded
Open this post in threaded view
|

Re: Can't set environment variable on OpenBSD 3.8

Alexander Hall
In reply to this post by Tomas-7
Tomas wrote:

> I cant set environment variable on OpenBSD 3.8. I issue command env
> testvar=var and I get printout with all the environment variables:
>
> PS1=#
> ...
> testvar=var

> And after that I issue command env and I get printout without my testvar:
>
> PS1=#
> ...
>
> What could I be doing wrong?
>

env(1) only affects the environment for the command it is told to run
(if any). It does not alter the current environment. This may not be
obvious from ``man env''.

man ksh
man csh
...
will tell you how to modify the current environment. Don't forget to export.

e.g. for ksh/sh:

export testvar=var

/Alexander