473,545 Members | 1,744 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to change the value of PS1 from within a c program

Hi all,

we can simply change value of PS1 from command prompt .
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 ?
regards
rahul

Apr 3 '06 #1
3 2811
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
Apr 3 '06 #2
vatsa wrote:
Hi all,

we can simply change value of PS1 from command prompt .
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 ?

comp.unix.progr ammer is the place to ask.

Do remember that the PS1 is a shell variable.
Your program is a child of the shell. You cannot
change the parents environment.
Apr 3 '06 #3
ro******@ibd.nr c-cnrc.gc.ca (Walter Roberson) writes:
[...]
<OT>
[...]
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".


Non-exported variables aren't referred to as "environmen t variables",
and "local environment variable" is a contradiction. The distiction
is between "environmen t variables" and "shell variables".

comp.unix.shell is a more appropriate place for this -- but I think
it's a FAQ there.
<OT>

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Apr 3 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2599
by: Richard Cornford | last post by:
For the last couple of months I have been trying to get the next round of updates to the FAQ underway and been being thwarted by a heavy workload (the project I am working on has to be finished an QA tested for a new year release. I don't think that going to prove practical, but there is no harm in trying :) and some serious family...
3
7057
by: Robb Gilmore | last post by:
Hello, We have a C#.NET app which is calling a Java webservice. We use the wsdl file exportted from the java webservice to create our web-reference in Visual Studio. We are able to create the parameter classes and call the webservice just fine. Our problem is, within our .Net app, we have some value objects ( like floats, for instance...
3
4984
by: Tom | last post by:
I am writing a Visual basic .Net database application. There are many forms that first let you select and look at a DB record and then when you click a "modify" button you are allowed to change data in the text boxes. Then an "update" button saves the data back to the database. What is the best way to change several properties on most of...
45
18791
by: Zytan | last post by:
This returns the following error: "Cannot modify the return value of 'System.Collections.Generic.List<MyStruct>.this' because it is not a variable" and I have no idea why! Do lists return copies of their elements? Why can't I change the element itself? class Program { private struct MyStruct
5
1857
by: raha | last post by:
hi. Is there any body to help me? I am writing a web program. I have some forms. each form have some controls and users can edit the controls. finally they can save their forms. I would like to add an ability to my program. In fact I want to have an Icon that change, when a user change the value of a control of form such as textbox ,...
6
2809
by: zhangsonglovexiaoniuniu | last post by:
Dear all, I need you help. here the program: char a = 0x91; printf("%x",a);
5
1403
by: Pascal | last post by:
Hello This is, below, a piece of code that I have a problem with: In the program (french description here http://www.scalpa.info/carre_install_clickonce/aide_carre.htm) a number is generated in the interval given by the value of nudNumMin and nudNumMax. In the user interface can be created several "projects" appearing in a listbox, which...
8
1997
by: want.to.be.professer | last post by:
#include <iostream> using namespace std; // Check if N is constant template <int N> class ValidateConstInt{}; int main() { const int constValue = 12;
7
4192
by: jeddiki | last post by:
Hi, I am using a function called htmlwrap() which states that it does NOT add a "<br>" to the 70 character line so that it forces a line wrap. ( the script safely wraps long words without destroying html tags which wordwrap has a tendency of doing! )) What I want to do is add that line break so that it DOES force a line wrap - but I am...
0
7464
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7396
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7805
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
5968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4943
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3449
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3440
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1012
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
700
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.