| Author |
Getting the System prompt character in a Java program
|
Jayesh Netravali
Greenhorn
Joined: May 07, 2003
Posts: 12
|
|
Hi, Is there some way in which I can get the last character in the prompt sign of my system. For e.g. in Windows the prompt ends with a '>' sign. In Unix it might end with a '$' sign or a '#' etc. I want to know if this last character of the prompt can be accessed in a Java program. Thanks in advance, Jayesh
|
 |
Jonathan Cone
Greenhorn
Joined: May 22, 2005
Posts: 24
|
|
Though I don't know if you could (easily) programatically capture this character, however, you might be interested in: I'm not sure what the range of values this returns is, but you may be able to wrestle with it inside a switch construct to produce the desired effect. If you figure out a better solution, let us know!
|
 |
Roshini Sridharan
Ranch Hand
Joined: Jan 16, 2001
Posts: 143
|
|
Hi, Why not find the OS type and then fix the prompt values accordingly !! you can get the OS Name through String os = System.getProperty("os.name") Hope this helps. Regards Roshini
|
 |
Joe Ess
Bartender
Joined: Oct 29, 2001
Posts: 8265
|
|
|
The prompt is configured via environment variables. In Windows, the environment variable is named "PROMPT". The default value is "$P$G" where "$P" indicates the path and "$G" indicates the greater-than character (other options include $D for current date and $T for current time). In the *nix world it's a bit more involved because one can configure colors as well as characters. By convention root uses a "#" and users have a "$". The "PS1" environment variable is what holds these values.
|
"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
|
 |
 |
|
|
subject: Getting the System prompt character in a Java program
|
|
|