1831219 Members
2978 Online
110021 Solutions
New Discussion

variable

 
SOLVED
Go to solution
Chakravarthi
Trusted Contributor

variable

Hi all,

How do i export a variable with read permissions

regards
chakri
5 REPLIES 5
John Meissner
Esteemed Contributor

Re: variable

variables don't have permissions the same way a file does. When you export it you should be able to read that variable until you unset it. to set a variable in a script it is as simple as:

variable=value

to recall that variable in the script you could:

echo $variable

do you need to export the variable so that it can be used outside of a script? If so then you just have to follow my first example at the command line.

if you need to export a variable such as your DISPLAY just type:

export DISPLAY=workstation:0.0

Is any of this what you are looking for?
All paths lead to destiny
Chakravarthi
Trusted Contributor

Re: variable

other than export in linux there is a command with which you can export a variable with permissions,, looking for that command

thx
chakri
Tom Maloy
Respected Contributor

Re: variable

Export is used in sh and ksh. I believe that "set" is used in csh. Are you trying to export in a specific shell?
Carpe diem!
Steven Mertens
Trusted Contributor
Solution

Re: variable

hi,

You can do it with typeset ( with pdksh)

ex.

[ smertens@thalia:/home/smertens ] [ 20021202 18:33:58 ]
$ typeset -r y=bla
[ smertens@thalia:/home/smertens ] [ 20021202 18:34:40 ]
$ y=blabla
ksh: y: is read only


hope this helps.

Steven
Steven Mertens
Trusted Contributor

Re: variable

hi

I just found out you can also
use the command readonly
to set vars readonly. :)


rgds.

Steven