Results 1 to 6 of 6
Hi All,
I am developing interactive Command line interface(CLI) for my application and the application is jboss running on linux rel4, So this CLI is client application which connect my ...
- 07-26-2007 #1Just Joined!
- Join Date
- Jul 2007
- Posts
- 2
Command Line interface?
Hi All,
I am developing interactive Command line interface(CLI) for my application and the application is jboss running on linux rel4, So this CLI is client application which connect my service. So any command given in CLI prompt will be written to server application and this command is processed application and result is sent read again in client and this result is printed in STDOUT. and print prompt as below.
#coam>
But in this case I cannot leverage any shell features like up/down arrow to display previous commands or left/right arrow to traverse through command so that i can edit any portion command. How can i achieve this feature ? I understand some concept of TTY and PTY to be used here.
Any help regarding this is really very helpful.
thanks in advance
mallick
- 07-27-2007 #2
Well IANA Java developer, or really a developer for that matter, however at the lowest level hitting up or down would move a pointer back or forward through the history stack, printing the contents after each arrow hit, and probably loading the contents in some buffer. Editing operations on that buffer... IDK exactly how to do that. Shouldn't be too hard.
- 07-27-2007 #3Just Joined!
- Join Date
- Jul 2007
- Posts
- 2
I am not looking the CLI client to be in java, It can be in C also .
thanks
Mallick
- 07-27-2007 #4
Then there you go, implement a stack for the history, and have a loop waiting for input. Have an if statement in there that looks for the up arrow, and if up move stack pointer up and print the contents of whetever is pointed to. There are some pretty good C programmers floating around on here, who can probably help you with editing in terms of the line.
- 07-27-2007 #5
Well, in C, this is a whole different puppy.
Obviously, creating the basic prompt is simple enough. For doing things such as up/down arrows, tab-completion, etc., I'd recommend that you look into changing your terminal to use noncanonical input:
Noncanonical Input - The GNU C Library
This and this may help in implementing it for your terminal.
Noncanonical input essentially passes input one character at a time to your program. This means that rather than receiving a line at a time, which the user has edited, you are receiving each character as pressed. So when they press 'a', you immediately receive 'a'. This is important because you can receive the arrow keys immediately and do what you will.
Obviously, you will need to manage what the user has already typed, and manage your own history. But I hope you see the basics of using this.DISTRO=Arch
Registered Linux User #388732
- 07-28-2007 #6Linux Engineer
- Join Date
- Apr 2006
- Location
- Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
- Posts
- 1,117
Hi.
Does not readline handle all these features? ... cheers, drlWelcome - get the most out of the forum by reading forum basics and guidelines: click here.
90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
We look forward to helping you with the challenge of the other 10%.
( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )


Reply With Quote