aspose file tools
The moose likes Java in General and the fly likes Getting the System prompt character in a Java program Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Getting the System prompt character in a Java program" Watch "Getting the System prompt character in a Java program" New topic
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]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Getting the System prompt character in a Java program
 
Similar Threads
Why does 1b seem so freakin tricky to me.
Can webstart Help ?
How a character save in 2 bytes in Java?
Differences between System.getProperty("file.seperator") and File.pathSeparator
Command Prompt ?