terminal IO for CLI devlopment


 
Thread Tools Search this Thread
Top Forums Programming terminal IO for CLI devlopment
# 1  
Old 05-23-2010
terminal IO for CLI devlopment

Hi all,

Am trying to develop CLI kind of program which does a telcom switch configuration [same like cisco IOS cli]. I have to provide a terminal and a prompt to user for that I did following:
Code:
 static struct termios old_term;
 struct termios new_term;

 tcgetattr(STDIN_FILENO, &old_term);
 new_term = old_term;
 new_term.c_lflag &= ~(ICANON | ECHO);
 tcsetattr(STDIN_FILENO, TCSANOW, &new_term);

This giving me a good control prompt where I can enter whole command string and history & tab features are working too..

But the problem is return key seems not working. When I just press enter key the prompt doesn't go to next line it stays on the same line and shows me next prompt.

if I press 4 times enter key .. it looks like
Code:
cli>cli>cli>cli>cli>

why its not entering to new line? please suggest..

Thanks...

Last edited by pludi; 05-25-2010 at 02:08 AM.. Reason: there is no [output], only [code]
# 2  
Old 05-24-2010
is ECHONL set? Does not look like it to me. If not set then the terminal will not echo a newline.
# 3  
Old 05-25-2010
hi jim,

thanks for your response ..

yeah actually am coding for non-canonical mode its ICANON is unset.
& ECHONL will work only when ICANON is set so...

is there any way to have new line enabled for non-canonical mode?? I need to have some way to get the prompt new line when return key is pressed.
# 4  
Old 05-25-2010
Turn off echo completely and printf every keystroke as you read it - only choice I can see.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Running a command in another cli

I am writing a script to login to to a mongo DB node and get the status of that machine. The usual work flow is : # mongo admin -u root -p root MongoDB shell version: 3.0.11 connecting to: admin rs0:SECONDARY> Then in the new prompt I can run a command to check status : ... (0 Replies)
Discussion started by: Junaid Subhani
0 Replies

2. Shell Programming and Scripting

Wireless connecting via CLI/Terminal

Do you use the CLI a lot and encounter new Wi-Fi sources, but don't want to/can't remember the commands to connect to the Internet?? I'm lazy. I mean, that's what scripting is for, right?? Efficiency means obtaining the maximum result with maximum laziness. I wrote this small script a while ago and... (0 Replies)
Discussion started by: Huitzilopochtli
0 Replies

3. Shell Programming and Scripting

Print Terminal Output Exactly how it Appears in the Terminal to a New Text File

Hello All, I have a text file containing output from a command that contains lots of escape/control characters that when viewed using vi or view, looks like jibberish. But when viewed using the cat command the output is formatted properly. Is there any way to take the output from the cat... (7 Replies)
Discussion started by: mrm5102
7 Replies

4. Shell Programming and Scripting

Cannot get terminal application to launch with a graphical launcher when successful in terminal

I have been having an extremely annoying problem. For the record, I am relatively new at this. I've only been working with unix-based OS's for roughly two years, mostly Xubuntu and some Kali. I am pretty familiar with the BASH language, as that's the default shell for debian. Now, I've made this... (16 Replies)
Discussion started by: Huitzilopochtli
16 Replies

5. UNIX for Dummies Questions & Answers

Does DOS has a terminal or pseudo terminal?

I am wondering if the DOS console works like the unix terminal? (1 Reply)
Discussion started by: vistastar
1 Replies

6. UNIX for Dummies Questions & Answers

Gnuplot wxt terminal vs x11 terminal

Hi, I installed ubuntu recently on my pc. And I installed gnuplot as well. When I first started working with gnuplot it was working . I did a plot and when I wanted to fit my data something happened and not the default terminal of gnuplot is xwt! I changed it to: set terminal x11, but it... (0 Replies)
Discussion started by: cosmologist
0 Replies

7. UNIX for Advanced & Expert Users

Pseudo-terminal will not be allocated because stdin is not a terminal.

I am trying to automate a SSH login using Keys using the following command ssh -i id_rsa usernamw@ipaddr. I am successful in doing this and i am getting the Warning Screen and I logon successfully. but when I am executing the command tail -1cf put.dat | ssh -i id_rsa username@ipaddr > get.dat ... (1 Reply)
Discussion started by: Shivdatta
1 Replies

8. UNIX for Dummies Questions & Answers

Some CLI questions

I use Ubuntu Linux, and I'd like to become more familiar with the CLI. I have these questions: 1) How to remove a directory that is not empty? The only option in man rmdir is -p and that does not do what I need. rm -R needs sudo for some reason. 2) What is a CLI command to make all the files... (3 Replies)
Discussion started by: dotancohen
3 Replies

9. UNIX for Advanced & Expert Users

connecting to unix through hyper terminal - as a dumb terminal

I just changed from windows NT to XP and I am no longer able to connect to my unix system. I used to use hyper terminal -- which acts as dumb terminal to my main frame unix system. I think one of the options used to be "direct to comX". This option isn't listed now. I use a serial port and the... (2 Replies)
Discussion started by: michelle
2 Replies
Login or Register to Ask a Question