Thread: Interactive vs non-interactive terminal session question

  1. #1
    Banned
    Join Date
    May 2007
    Location
    Berkeley, CA
    Posts
    329

    Interactive vs non-interactive terminal session question

    I get the "OK: " prompt when I connect to a remote forum
    interactively. Ie, I do something like
    ssh [email protected] /bin/zsh -i

    m-net% tty
    /dev/ttyp3
    m-net% bbs
    YAPP 3.1.1 Copyright (c)1995 Armidale Software
    Registered to: Arbornet

    Welcome to the
    June General Conference

    Fairwitness: jerryr

    First item 1, last 122

    Ok: quit

    Now leaving June General...
    However, I don't get the "OK: " prompt when I connect non-
    interactively. Ie, I do something like
    ssh -T [email protected] /bin/zsh -i

    m-net% tty
    not a tty
    m-net% bbs
    YAPP 3.1.1 Copyright (c)1995 Armidale Software
    Registered to: Arbornet

    Welcome to the
    June General Conference

    Fairwitness: jerryr

    First item 1, last 122
    quit

    Now leaving June General...
    m-net%
    The question is why doesn't the "OK: "prompt appear in the non-
    interactive session?

  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Perhaps the "OK:" prompt is printed to standard error (stderr). I could see stderr messages appearing in a real tty but not in a pseudo one (though I'm really just guessing). Here's how you could find out.
    Code:
    $ echo This is printed to stdout
    This is printed to stdout
    $ echo This is printed to stderr >&2
    This is printed to stderr
    $
    If the second message doesn't appear, my guess is probably right.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  3. #3
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    ssh tells the remote session whether the connection is interactive or not. So the other side knows, and might change its behavior accordingly.

    It makes no sense to display a prompt in a non-interactive session, since there is nobody there to respond to the prompt. Don't lie about whether your session is interactive
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. controlling terminal question
    By Overworked_PhD in forum Linux Programming
    Replies: 3
    Last Post: 10-01-2008, 09:20 PM
  2. I need help to compile this code...
    By wise_ron in forum C Programming
    Replies: 17
    Last Post: 05-07-2006, 12:22 PM
  3. Newbie Question - fflush(stdin) & fpurge(stdin) on Mac and PC
    By tvsinesperanto in forum C Programming
    Replies: 34
    Last Post: 03-11-2006, 12:13 PM
  4. another exercise question
    By luigi40 in forum C# Programming
    Replies: 3
    Last Post: 11-28-2005, 03:52 PM
  5. what does this warningmean???
    By kreyes in forum C Programming
    Replies: 5
    Last Post: 03-04-2002, 07:53 AM