In article <11************ **********@v46g 2000cwv.googleg roups.com>,
vatsa <va*******@gmai l.com> wrote:
we can simply change value of PS1 from command prompt .
Perhaps on whatever system you are using, but the C language standard
does not know about any "command prompt" or any "PS1".
but I want to change the value of PS1 from within a c program. i tried
to do that using getenv & putenv. but it is n't working... .
i even wrote 1 code to print all environment variables, among them PS1
wasn't there. but when i use "set" command on command prompt, it
displays PS1 too among other environment variables...
how to do it ?
The C language standard does not assign meaning to any environment
variable or to the effect on the system of setting any particular
environment variable. Your question is thus really a question
specific to whatever operating system you are using; you should
ask in a more appropriate newsgroup.
<OT>
1) In Unix, setting an environment variable in a program only
affects subshells and never the shell that invoked the program.
Thus in Unix, what you want to do is not possible.
2) If PS1 does not appear amongst the environment variables, it
could be that it is a local environment variable. In the Bourne
family of shells (e.g., sh, ksh, bash), environment variables
must be "exported" in order to become available to subprocesses.
In the cshell family, this is expressed by "set" vs "setenv".
3) Shells usually offer a mechanism to execute a program and to
interpret the program output as a series of environment
variable settings. One of the more common syntax notations for
that is to use backquotes around the program invocation.
--
Prototypes are supertypes of their clones. -- maplesoft