• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Getting the System prompt character in a Java program

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic