C++ and Unix Shell Question 
Author Message
 C++ and Unix Shell Question

Quote:

>The only thing I know how to use is scanf. So I would like to learn
>answers to the following questions.
>(I understand that answers to some of these questions maybe quite
>involved so please feel free to direct me to a source rather than answer
>the question!)

These questions

        1.  Aren't germane to the C and C++ languages.
        2.  Are in direct violation of the comp.lang.c and comp.lang.c++
                charters.
        3.  Should be covered in any Unix programming FAQ (try
                ftp://rtfm.mit.edu under usenet-by-groups for comp.unix.*)

Quote:
>1) How to read "arrow" keys.

curses is the easiest, although you could match the strings given
by termcap/terminfo.

Quote:
>2) I notice that in certain shells backspace works, in others doesn't.
>What parameter or variable is responsible for that?

A lot of shells run the tty in "cooked" mode.  Among other things, this
results in input being fed to you a line at a time, and the tty
driver allowing basic line-editing using user-specified characters
(in this case, it's the erase character).

In some cases, the back-space key is mapped to the delete character.  If
erase is set to ^H,  the delete will be passed through to the application.

Quote:
>3) How do I enable emacs bindings?

You use the GNU readline library.

Quote:
>4) I don't know if this is a tcsh feature (which is the shell that I
>prefer), but my shell stops taking input either after 1024 or 2048
>characters. How do I change that?

Use "raw" mode and do your own handling of erase/kill/etc.

--
If a President of the United States ever lied to the American people he
should resign," --- William Clinton, 1974 while running for the US House of
Representatives responding to a question about President Nixon.



Fri, 20 Apr 2001 03:00:00 GMT  
 C++ and Unix Shell Question
Hi,

I'm trying to develop a small application that is interactive in the
same way as, say, gnuplot.The user types commands at a command prompt.
The only thing I know how to use is scanf. So I would like to learn
answers to the following questions.
(I understand that answers to some of these questions maybe quite
involved so please feel free to direct me to a source rather than answer
the question!)

1) How to read "arrow" keys.
2) I notice that in certain shells backspace works, in others doesn't.
What parameter or variable is responsible for that?
3) How do I enable emacs bindings?
4) I don't know if this is a tcsh feature (which is the shell that I
prefer), but my shell stops taking input either after 1024 or 2048
characters. How do I change that?

I know it's quite obnoxious to ask 4 questions in the same message, so
sorry and thanks a lot in advance!

Pavel




Sat, 21 Apr 2001 03:00:00 GMT  
 C++ and Unix Shell Question

Quote:

> I'm trying to develop a small application that is interactive in the
> same way as, say, gnuplot.The user types commands at a command prompt.
> The only thing I know how to use is scanf. So I would like to learn

Don't use scanf().  Ever.  If you must do something similar, use
fgets() and sscanf().  This prevents scanf() reading right over the
newline in order to satisfy an input and confusing the poor person
typing at it.

Quote:
> answers to the following questions.
> (I understand that answers to some of these questions maybe quite
> involved so please feel free to direct me to a source rather than answer
> the question!)

> 1) How to read "arrow" keys.

Use the "readline" library.

Quote:
> 2) I notice that in certain shells backspace works, in others doesn't.
> What parameter or variable is responsible for that?

All of them should understand the setting used in your stty(1)
settings, but some of them are set up to understand both ASCII 8
(backspace) and ASCII 127 (delete) as "delete the last character".

Quote:
> 3) How do I enable emacs bindings?

Use the GNU "readline" library.

Quote:
> 4) I don't know if this is a tcsh feature (which is the shell that I
> prefer), but my shell stops taking input either after 1024 or 2048
> characters. How do I change that?

But your program has nothing whatsoever to do with the shell.  The
shell's limitations will not be the limitations of your program.
There is no need to worry about that issue.

Quote:
> I know it's quite obnoxious to ask 4 questions in the same message,
> so sorry and thanks a lot in advance!  

I wouldn't say it's obnoxious.   It's certainly bandwidth-efficient.
At least the 4 questions were related...

--



Sat, 21 Apr 2001 03:00:00 GMT  
 C++ and Unix Shell Question

Quote:
> Hi,

> I'm trying to develop a small application that is interactive in the
> same way as, say, gnuplot.The user types commands at a command prompt.
> The only thing I know how to use is scanf. So I would like to learn
> answers to the following questions.
> (I understand that answers to some of these questions maybe quite
> involved so please feel free to direct me to a source rather than answer
> the question!)

> 1) How to read "arrow" keys.
> 2) I notice that in certain shells backspace works, in others doesn't.
> What parameter or variable is responsible for that?
> 3) How do I enable emacs bindings?
> 4) I don't know if this is a tcsh feature (which is the shell that I
> prefer), but my shell stops taking input either after 1024 or 2048
> characters. How do I change that?

I wont (but could :)  get into too much detail...just check out the CURSES
library on your unix box.  All of this not defined by Standard C++.

--
<<<<<<<<<<  Blue Skies  >>>>>>>>>>>
<        Michael J. Tobler        >

< remove "no-spam-" when replying >
<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>



Mon, 23 Apr 2001 03:00:00 GMT  
 C++ and Unix Shell Question

Quote:
>> 1) How to read "arrow" keys.
>> 2) I notice that in certain shells backspace works, in others
doesn't.
>> What parameter or variable is responsible for that?
>> 3) How do I enable emacs bindings?
>> 4) I don't know if this is a tcsh feature (which is the shell that
I
>> prefer), but my shell stops taking input either after 1024 or 2048
>> characters. How do I change that?

Curses is overkill and will drive you mad for such a simple task.
The GNU readline library is exactly what you need.

Steve.



Mon, 30 Apr 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. C++/C/UNIX/Shell Help Needed !!!

2. C++/C/UNIX/Shell Help Needed !!!

3. unix shell script execution

4. unix shell command line and interpreter

5. A C program that calls unix shell scripts

6. Convert Unix Shell Program to C

7. how to call a unix shell script from a c program

8. returning output of UNIX shell commands

9. From a Unix shell script to a C function

10. BOOKS HOW TO UNIX/PERL/C-SHELL PROGRAMMING???

11. DESPERATE FOR UNIX/C/SHELL

12. Q: Getting UNIX shell varibles passed into a C program

 

 
Powered by phpBB® Forum Software