Terminal Controll...

Discussion in 'C Programming' started by Brendan zerofor0je, Nov 8, 2003.

  1. Hello,

    I've written a small reverse-telnet client that connects to a server that
    handles all the clients.

    the reverse telnet node ( whitch i will refer to as rtn from now on) works
    by opening up a pty, and with a simple select() it passes data between the
    sockets and the pty that /bin/sh runs on.

    Meanwihle, the server program( that i will refer to as trc from now on)
    sits and listens for nodes running rtn, once a node connects trc takes
    controll over it; my problem?

    once a rtn node connects to trc2, it works fine, but im having problems on
    the input line ( i've tryed 'nc' in listen mode and it works fine, even
    the mangled prompt )

    Anyway, my problem is the terminal doesnt work properly for example tpying
    on the trc prompt i get this undesired result;

    hardk0re$ ls -lah /u lo bi mo ls -lah /usr/local/bin/mozilla
    -rwxr-xr-x 1 root root 2.9k Jun 19 17:51
    /usr/local/bin/mozilla hardk0re$

    As you can see, when i type text it does not 'expand' but after i press
    'enter' the desired output that i want on the terminal line is printed
    out.

    Zhivago from #C freenode aksed me to compile this small program;
    ---
    #include <stdio.h>
    #include <stdlib.h>

    int main(){
    int c;
    c = getchar();
    printf("%c\n",c);
    }
    ---
    As you would expect on a normal terminal ( not my cruddy trc :p ) it
    prints out;
    hardk0re$ ./a.out
    m <- the letter you typed
    m <- the letter printf'd back
    hardk0re$

    But on trc it behaves oddly,

    hardk0re$ ./a.out
    ../a.out
    m
    m
    m
    hardk0re$

    If anyone knows how to rememdy this i would be very pleased to hear it,
    thank you in advance.
    Brendan zerofor0je, Nov 8, 2003
    #1
    1. Advertising

  2. It sounds like you're using cbreak mode instead of raw mode.
    Cbreak mode forces input to be delimited with newlines. Raw
    mode allows you to handle things one character at a time, but
    it also requires you to handle such things as backspaces and
    other forms of input line editing.

    --

    Fletcher Glenn

    Brendan zerofor0je wrote:
    > Hello,
    >
    > I've written a small reverse-telnet client that connects to a server that
    > handles all the clients.
    >
    > the reverse telnet node ( whitch i will refer to as rtn from now on) works
    > by opening up a pty, and with a simple select() it passes data between the
    > sockets and the pty that /bin/sh runs on.
    >
    > Meanwihle, the server program( that i will refer to as trc from now on)
    > sits and listens for nodes running rtn, once a node connects trc takes
    > controll over it; my problem?
    >
    > once a rtn node connects to trc2, it works fine, but im having problems on
    > the input line ( i've tryed 'nc' in listen mode and it works fine, even
    > the mangled prompt )
    >
    > Anyway, my problem is the terminal doesnt work properly for example tpying
    > on the trc prompt i get this undesired result;
    >
    > hardk0re$ ls -lah /u lo bi mo ls -lah /usr/local/bin/mozilla
    > -rwxr-xr-x 1 root root 2.9k Jun 19 17:51
    > /usr/local/bin/mozilla hardk0re$
    >
    > As you can see, when i type text it does not 'expand' but after i press
    > 'enter' the desired output that i want on the terminal line is printed
    > out.
    >
    > Zhivago from #C freenode aksed me to compile this small program;
    > ---
    > #include <stdio.h>
    > #include <stdlib.h>
    >
    > int main(){
    > int c;
    > c = getchar();
    > printf("%c\n",c);
    > }
    > ---
    > As you would expect on a normal terminal ( not my cruddy trc :p ) it
    > prints out;
    > hardk0re$ ./a.out
    > m <- the letter you typed
    > m <- the letter printf'd back
    > hardk0re$
    >
    > But on trc it behaves oddly,
    >
    > hardk0re$ ./a.out
    > ./a.out
    > m
    > m
    > m
    > hardk0re$
    >
    > If anyone knows how to rememdy this i would be very pleased to hear it,
    > thank you in advance.
    Fletcher Glenn, Nov 8, 2003
    #2
    1. Advertising

  3. On Sat, 08 Nov 2003 00:50:46 +0000, Fletcher Glenn wrote:

    > It sounds like you're using cbreak mode instead of raw mode.
    > Cbreak mode forces input to be delimited with newlines. Raw
    > mode allows you to handle things one character at a time, but
    > it also requires you to handle such things as backspaces and
    > other forms of input line editing.
    >
    > --
    >
    > Fletcher Glenn
    >
    > Brendan zerofor0je wrote:
    >> Hello,
    >>
    >> I've written a small reverse-telnet client that connects to a server that
    >> handles all the clients.
    >>
    >> the reverse telnet node ( whitch i will refer to as rtn from now on) works
    >> by opening up a pty, and with a simple select() it passes data between the
    >> sockets and the pty that /bin/sh runs on.
    >>
    >> Meanwihle, the server program( that i will refer to as trc from now on)
    >> sits and listens for nodes running rtn, once a node connects trc takes
    >> controll over it; my problem?
    >>
    >> once a rtn node connects to trc2, it works fine, but im having problems on
    >> the input line ( i've tryed 'nc' in listen mode and it works fine, even
    >> the mangled prompt )
    >>
    >> Anyway, my problem is the terminal doesnt work properly for example tpying
    >> on the trc prompt i get this undesired result;
    >>
    >> hardk0re$ ls -lah /u lo bi mo ls -lah /usr/local/bin/mozilla
    >> -rwxr-xr-x 1 root root 2.9k Jun 19 17:51
    >> /usr/local/bin/mozilla hardk0re$
    >>
    >> As you can see, when i type text it does not 'expand' but after i press
    >> 'enter' the desired output that i want on the terminal line is printed
    >> out.
    >>
    >> Zhivago from #C freenode aksed me to compile this small program;
    >> ---
    >> #include <stdio.h>
    >> #include <stdlib.h>
    >>
    >> int main(){
    >> int c;
    >> c = getchar();
    >> printf("%c\n",c);
    >> }
    >> ---
    >> As you would expect on a normal terminal ( not my cruddy trc :p ) it
    >> prints out;
    >> hardk0re$ ./a.out
    >> m <- the letter you typed
    >> m <- the letter printf'd back
    >> hardk0re$
    >>
    >> But on trc it behaves oddly,
    >>
    >> hardk0re$ ./a.out
    >> ./a.out
    >> m
    >> m
    >> m
    >> hardk0re$
    >>
    >> If anyone knows how to rememdy this i would be very pleased to hear it,
    >> thank you in advance.


    Thanks, It worked!
    Brendan zerofor0je, Nov 8, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Daniel
    Replies:
    1
    Views:
    342
    Victor Bazarov
    Dec 31, 2003
  2. Replies:
    25
    Views:
    730
  3. gaurav kashyap
    Replies:
    3
    Views:
    6,622
    Paul Boddie
    Oct 31, 2008
  4. and

    files permissions controll

    and, Jun 19, 2009, in forum: C Programming
    Replies:
    2
    Views:
    314
    James Kuyper
    Jun 19, 2009
  5. Steve
    Replies:
    2
    Views:
    923
    edicionsdigitals.com edicions digitals xarxa socia
    Dec 7, 2010
Loading...

Share This Page