LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 09-16-2003, 11:06 PM   #1
pshea
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

username@hostnamecurrentdirectory$

any help would be greatly appreciated.
 
  


Reply



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 09:32 PM
change the boot prompt alaios Linux - Newbie 1 07-30-2004 10:23 PM
How to change parameter values of a function in shell script? Bassam Programming 0 01-25-2004 09:52 AM
how to change my prompt ? lzg8056 Linux - Newbie 14 11-30-2003 09:00 PM
how to change prompt ashesh Linux - General 5 04-16-2003 06:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:23 PM.

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