Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 09-17-2003, 12:06 AM   #1
LQ Newbie
Registered: Sep 2003
Posts: 1

Rep: Reputation: 0
Question Change prompt values from within a C++ program

I am trying to write a "minishell" program in C++ to demonstrate execv, fork(), wait(), getpid(), etc. I need to have the C++ program display a prompt to the user of the format "username@hostname:current directory:$" I have tried the following without success:

int main()

putenv("PS1 = \u@\h\w$");
char *prompt = getenv("PS1");
cout << prompt;


The putenv as I have it is giving me compilation errors and the cout << prompt is giving me the values of PS1.

I would like cout << prompt; to give me the following


any help would be greatly appreciated.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Really strange change of string values in C realos Programming 34 08-08-2005 10:32 PM
change the boot prompt alaios Linux - Newbie 1 07-30-2004 11:23 PM
How to change parameter values of a function in shell script? Bassam Programming 0 01-25-2004 10:52 AM
how to change my prompt ? lzg8056 Linux - Newbie 14 11-30-2003 10:00 PM
how to change prompt ashesh Linux - General 5 04-16-2003 07:14 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:35 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration