Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Env variable change
Hello
How to set the environment variable through tcl.

setenv <name> <value>

if i execute the same it not working.Is there any specific way in tcl
where in we can set the variable.

Thanks
chendu


Report this thread to moderator Post Follow-up to this message
Old Post
Chendu
08-21-07 03:14 AM


Re: Env variable change
Chendu schrieb:
> Hello
> How to set the environment variable through tcl.
>
> setenv <name> <value>
>
> if i execute the same it not working.Is there any specific way in tcl
> where in we can set the variable.
>
set ::env(name) value

e.g.

set ::env(PATH) /usr/local/bin


Michael

Report this thread to moderator Post Follow-up to this message
Old Post
Michael Schlenker
08-21-07 09:42 AM


Re: Env variable change
Michael Schlenker wrote:
> Chendu schrieb: 
>
> set ::env(name) value

For those that like setenv...

proc setenv {name value} {
set ::env($name) $value
}

Donal.

Report this thread to moderator Post Follow-up to this message
Old Post
Donal K. Fellows
08-21-07 09:42 AM


Re: Env variable change
In article <fae9o7$594$1@godfrey.mcc.ac.uk>,
Donal K. Fellows <donal.k.fellows@manchester.ac.uk> wrote:
>Michael Schlenker wrote: 
>
>For those that like setenv...
>
>   proc setenv {name value} {
>      set ::env($name) $value
>   }
>
>Donal.

Understand, this does NOT set the environment of the process which
*invokes* a Tcl application; the latter is often what questioners
think they want <URL: http://wiki.tcl.tk/4282 >.

Report this thread to moderator Post Follow-up to this message
Old Post
Cameron Laird
08-21-07 01:09 PM


Re: Env variable change
Cameron Laird wrote:
> Understand, this does NOT set the environment of the process which
> *invokes* a Tcl application; the latter is often what questioners
> think they want <URL: http://wiki.tcl.tk/4282 >.

Mind you, nothing does except editing a file/registry entry[*] and
restarting the shell or reloading its configuration. This is by
deliberate design, and applies to thing other than Tcl.

Donal.
[* Depending on platform. ]

Report this thread to moderator Post Follow-up to this message
Old Post
Donal K. Fellows
08-21-07 01:09 PM


Re: Env variable change
In article <faemmk$8r8$1@godfrey.mcc.ac.uk>,
Donal K. Fellows <donal.k.fellows@manchester.ac.uk> wrote:
>Cameron Laird wrote: 
>
>Mind you, nothing does except editing a file/registry entry[*] and
>restarting the shell or reloading its configuration. This is by
>deliberate design, and applies to thing other than Tcl.

Report this thread to moderator Post Follow-up to this message
Old Post
Cameron Laird
08-22-07 12:11 AM


Re: Env variable change
"Donal K. Fellows" <donal.k.fellows@manchester.ac.uk> wrote:

> Cameron Laird wrote: 
>
> Mind you, nothing does except editing a file/registry entry[*] and
> restarting the shell or reloading its configuration. This is by
> deliberate design, and applies to thing other than Tcl.
>
> Donal.
> [* Depending on platform. ]

Sufficient knowledge of the internal data structures of the platform
lets you do theoretically impossible things.  In my early career as a
software developer, I wrote a large collection of DOS programs that
communicated with each other by manipulating the "root" environment.

(There was much about that project I should have done differently, or
not done at all.  Basing the entire architecture of the user interface
and network communication around the capabilities of a Hercules Network
Card Plus made for a fast and reasonably pretty system, but when the
supply of monochrome monitors started to dry up...)

Report this thread to moderator Post Follow-up to this message
Old Post
Alan Anderson
08-22-07 03:11 AM


Re: Env variable change
Alan Anderson wrote:
> Sufficient knowledge of the internal data structures of the platform
> lets you do theoretically impossible things.  In my early career as a
> software developer, I wrote a large collection of DOS programs that
> communicated with each other by manipulating the "root" environment.

You can't do that on "modern" systems, i.e. anything with virtual memory
or real memory protection! You either can't see the root environment at
all, or can't recognize it, or can't write it (the most common case.)

Donal.

Report this thread to moderator Post Follow-up to this message
Old Post
Donal K. Fellows
08-22-07 03:11 AM


Re: Env variable change
Donal K. Fellows wrote:
> Alan Anderson wrote: 
>
> You can't do that on "modern" systems, i.e. anything with virtual memory
> or real memory protection! You either can't see the root environment at
> all, or can't recognize it, or can't write it (the most common case.)

You can, if you have enough privileges -- or at least the right ones.

After all that is how ACPs work.

--
+--------------------------------+---------------------------------------+
| Gerald W. Lester                                                       |
|"The man who fights for his ideals is the man who is alive." - Cervantes|
+------------------------------------------------------------------------+

Report this thread to moderator Post Follow-up to this message
Old Post
Gerald W. Lester
08-22-07 03:11 AM


Re: Env variable change
On Aug 22, 6:43 am, "Gerald W. Lester" <Gerald.Les...@cox.net> wrote:
> Donal K. Fellows wrote: 
> 
>
> You can, if you have enough privileges -- or at least the right ones.
>
> After all that is how ACPs work.
>
> --
> +--------------------------------+---------------------------------------+
> | Gerald W. Lester                                                       |
> |"The man who fights for his ideals is the man who is alive." - Cervantes|
> +------------------------------------------------------------------------+

i am able to set env variable and able to get it with in the same tcl
script .

But if i want to access in the value in other tcl script with out
editing the shell rc file.

Is there any way
Process:
1.I would open a shell.
2.run a tcl script to set a env variable
3.run a second tcl script to accss the env  variable set by 1st
script.

i tried using as in wiki
source export myvar=<value>
but i am not able to get it. basically i am not able to get what
export does.

Thanks
chendu


Report this thread to moderator Post Follow-up to this message
Old Post
Chendu
08-23-07 09:24 AM


Sponsored Links




Last Thread Next Thread Next
Pages (2): [1] 2 »
Search this forum -> 
Post New Thread

Tcl archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 02:32 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.