Re: Terminal program in Java. Linux raw mode

Discussion in 'Java' started by Andreas Leitgeb, Aug 8, 2010.

  1. Kari Laine <> wrote:
    > I hope someone can put me in the right direction.
    > I am making front end to Byvac BV4626 multi IO card in Java. Part of the
    > implementation is little terminal program. Problem is the BV4626 wants
    > strings starting with escape. No when I read the System.in I don't get
    > escape.


    On Linux (and unices), you can enter a literal Esc-key, by quoting it:
    precede it with a (usually, unless redefined) <Ctrl>-V sequence.
    That way, it should be literally readable from System.in.

    Calling out to external program stty won't add much new platform-
    dependency, as switching the terminal to raw ... well, I don't think
    that the very concept even exists on windows command-lines.

    I once did something like that in a similar situation:
    static void raw(boolean on) {
    String s=on? "" : "-";
    try { Runtime.getRuntime().exec(new String [] {
    "sh", "-c", "stty "+s+"raw </dev/tty"}).waitFor();
    } catch (Exception e) {}
    }

    If you really need input of some special keys cross-platform from
    terminal through System.in, you can define your own meta-syntax,
    like \e for escape, and \\ for literal backslash...

    > Also if there already exist a terminal program written in Java, which
    > is GPL or BSD license - that would be optimal. Also I am after XMODEM
    > implementation with Java.


    Sorry, can't help with that.
     
    Andreas Leitgeb, Aug 8, 2010
    #1
    1. Advertising

  2. Andreas Leitgeb

    Arne Vajhøj Guest

    On 08-08-2010 17:10, Andreas Leitgeb wrote:
    > Kari Laine<> wrote:
    >> I hope someone can put me in the right direction.
    >> I am making front end to Byvac BV4626 multi IO card in Java. Part of the
    >> implementation is little terminal program. Problem is the BV4626 wants
    >> strings starting with escape. No when I read the System.in I don't get
    >> escape.

    >
    > On Linux (and unices), you can enter a literal Esc-key, by quoting it:
    > precede it with a (usually, unless redefined)<Ctrl>-V sequence.
    > That way, it should be literally readable from System.in.
    >
    > Calling out to external program stty won't add much new platform-
    > dependency, as switching the terminal to raw ... well, I don't think
    > that the very concept even exists on windows command-lines.
    >
    > I once did something like that in a similar situation:
    > static void raw(boolean on) {
    > String s=on? "" : "-";
    > try { Runtime.getRuntime().exec(new String [] {
    > "sh", "-c", "stty "+s+"raw</dev/tty"}).waitFor();
    > } catch (Exception e) {}
    > }
    >
    > If you really need input of some special keys cross-platform from
    > terminal through System.in, you can define your own meta-syntax,
    > like \e for escape, and \\ for literal backslash...


    The last suggestion sounds by far as the best solution to me!

    Arne
     
    Arne Vajhøj, Aug 9, 2010
    #2
    1. Advertising

  3. Andreas Leitgeb

    Arne Vajhøj Guest

    On 09-08-2010 02:45, Kari Laine wrote:
    > On 08/09/2010 03:35 AM, Arne Vajhøj wrote:
    >> On 08-08-2010 17:10, Andreas Leitgeb wrote:

    ....
    >> Arne

    >
    > Thanks a lot Arne !


    I think the thanks belong to Andreas ...

    Arne
     
    Arne Vajhøj, Aug 10, 2010
    #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. John J Lee
    Replies:
    3
    Views:
    552
    bruno at modulix
    Dec 1, 2005
  2. gaurav kashyap
    Replies:
    3
    Views:
    6,735
    Paul Boddie
    Oct 31, 2008
  3. Joshua Cranmer
    Replies:
    0
    Views:
    491
    Joshua Cranmer
    Aug 9, 2010
  4. Steve
    Replies:
    2
    Views:
    980
    edicionsdigitals.com edicions digitals xarxa socia
    Dec 7, 2010
  5. Ari Brown

    Terminal Session Raw Mode

    Ari Brown, Jul 30, 2007, in forum: Ruby
    Replies:
    1
    Views:
    123
Loading...

Share This Page