How to get different prompt?

How to get different prompt?

Post by AnilKumar.B » Thu, 11 Apr 2002 22:40:27



Hi all,

Can anyone provide me a solution for the following?

My requirement is( a C program) :
From the unix home directory if I execute the program,
the command prompt has to change to the name of the program that I execute.
Like
#anil:>      <---- This is my unix home dir

#anil:> Hello        <----If I run Hello
#Hello:>          <---It has to change to Hello.

And also I should be able to run commands from Hello prompt and if I type
QUIT it has to come back to  #anil:> prompt.

Thanks in advance
Anil

 
 
 

How to get different prompt?

Post by Josh Jone » Thu, 11 Apr 2002 23:51:56



> Can anyone provide me a solution for the following?

Well, we can provide some ideas...

Quote:> My requirement is( a C program) :
> From the unix home directory if I execute the program,
> the command prompt has to change to the name of the program that I execute.
> Like
> #anil:>      <---- This is my unix home dir

> #anil:> Hello        <----If I run Hello
> #Hello:>          <---It has to change to Hello.

> And also I should be able to run commands from Hello prompt and if I type
> QUIT it has to come back to  #anil:> prompt.

Since this sounds like a homework question I'll be vague.  Look on google
for the environmental variable that changes the prompt in bash.  This
should take about 5 minutes to find.  Now, do a 'man -k environment' and
look at the function calls that come up dealing with setting/getting
environmental variables.  I've never done this, so I may be wrong, but
this is the direction I would look in...  Also, if your "QUIT" is not
actually a separate program, then it looks like you may just need to
spawn a new shell and change the prompt.  At any rate, you have some
ideas.

--
  Joshua Jones  ::  jajones(at)cc.gatech.edu  ::  http://www.intmain.net

  "Quotes in .sigs are useless." -- Me

 
 
 

How to get different prompt?

Post by Jens.Toerr.. » Fri, 12 Apr 2002 00:24:15




>> Can anyone provide me a solution for the following?
> Well, we can provide some ideas...
>> My requirement is( a C program) :
>> From the unix home directory if I execute the program,
>> the command prompt has to change to the name of the program that I execute.
>> Like
>> #anil:>      <---- This is my unix home dir

>> #anil:> Hello        <----If I run Hello
>> #Hello:>          <---It has to change to Hello.

>> And also I should be able to run commands from Hello prompt and if I type
>> QUIT it has to come back to  #anil:> prompt.
> Since this sounds like a homework question I'll be vague.  Look on google
> for the environmental variable that changes the prompt in bash.  This
> should take about 5 minutes to find.  Now, do a 'man -k environment' and
> look at the function calls that come up dealing with setting/getting
> environmental variables.  I've never done this, so I may be wrong, but
> this is the direction I would look in...  Also, if your "QUIT" is not
> actually a separate program, then it looks like you may just need to
> spawn a new shell and change the prompt.  At any rate, you have some
> ideas.

He probably will have to spawn a new shell from his program because the
program can't change the environment of the shell he started the program
from. So, setting an environment variable from within his program and
then exiting won't help because only programs started from within his
program inherit the changed environment. Thus having a look at the man
pages for execl(), execlp() and friends (and, of course, setenv()) is
something that needs to be added to the TODO list.

                                       Regards, Jens
--
      _  _____  _____

  _  | |  | |    | |          AG Moebius, Institut fuer Molekuelphysik
 | |_| |  | |    | |          Fachbereich Physik, Freie Universitaet Berlin
  \___/ens|_|homs|_|oerring   Tel: ++49 (0)30 838 - 53394 / FAX: - 56046

 
 
 

1. Getting from the ok prompt to the OS login prompt?

Greetings all...

I installed Solaris 9 on a Sun Fire V100 (I connected to the box from
a Windows laptop running HyperTerminal as described in the box's
documentation)... The installation went perfectly, and when I was
done, I logged into the box (from HyperTerminal), poked around a bit
to make sure that everything was OK, then logged out (by typing
"exit")...

At this point, I was at the OS's login prompt. I then shut down
HyperTerminal, and without ever disconnecting the laptop from the LOM
port, I immediately fired HyperTerminal back up, at which point I got
an "ok" prompt.

I haven't been able to find any information about getting from the ok
prompt back to the OS's login prompt. Here's what I've found so far:

- I spoke to a Solaris administrator who said that if I'm getting the
ok prompt, the machine is not in a "booted" state.
- I found some information on the mailing list archives that I've
looked through so far regarding the fact that the machine might be in
suspend mode. A couple of things with regard to this:
    - During the installation process, I was never asked whether or
not I wanted to enable suspend mode on the machine if it was not used
for 30 minutes. Is this bad? Should I have seen this?
    - I closed HyperTerminal and started it back up immediately, so
unless the box detected that the terminal session had ended and
immediately put itself in suspend mode, suspend mode cannot be the
cause of the problem.
- I found information about getting back to the OS prompt from the lom
prompt (by typing "console"). Is there an ok prompt equivalent? The
administrator I talked to suggested trying "go". However, this still
sounded like a way of coming out of suspend mode.

I haven't found anything that sounds like the right answer in the
box's documentation... Any help, suggestions, pointers to the
appropriate information would be greatly appreciated...

Cheers...

Dave Bruzzone

2. ld.so 1.3

3. How can I make my prompt a different color?

4. backing up to remote tape device on Solaris

5. ppp scripts for different prompts

6. Zoom 56K V90 modem ... HELP !

7. how to prompt to different color

8. XFree86 Config Settings for MAG MX17F Monitor

9. Why is BASH PS1 prompt different when I su ?

10. Getting rid of "F?" prompt on system boot?

11. Getting the time in prompt for KSH

12. Computer gets stuck at boot up, only "LI" of the LILO prompt shows

13. Getting Rid of ANSI-ized Command Line Prompts