As was foretold, we've added advertisements to the forums! If you have questions, or if you encounter any bugs, please visit this thread: https://forums.penny-arcade.com/discussion/240191/forum-advertisement-faq-and-reports-thread/
Options

putty, ssh, pulling down previous line

ÆthelredÆthelred Registered User regular
Hopefully someone here will know what's up with this:

I'm using putty to access a server via SSH. When I press 'up' on the keyboard, I expect to get back the line I previously entered. I don't - instead, I get ^[[A. This is not very helpful. I don't get this when accessing another server. Is this a setting the server makes, rather than the accessing client?

pokes: 1505 8032 8399
Æthelred on

Posts

  • Options
    DedianDedian Registered User regular
    edited April 2010
    What shell are you using on the server?

    Dedian on
  • Options
    MadpandaMadpanda suburbs west of chicagoRegistered User regular
    edited April 2010
    Do you have different keyboard settings per host? In putty go to Terminal->Keyboard and see if anything is different from the problem host compared to your default settings.

    Also it could be the terminal settings on the hosts itself, I just started getting back into linux so I can't tell you exactly where to go.

    Madpanda on
    camo_sig2.png
    Steam/PSN/XBL/Minecraft / LoL / - Benevicious | WoW - Duckwood - Rajhek
  • Options
    BarrakkethBarrakketh Registered User regular
    edited April 2010
    Æthelred wrote: »
    Hopefully someone here will know what's up with this:

    I'm using putty to access a server via SSH. When I press 'up' on the keyboard, I expect to get back the line I previously entered. I don't - instead, I get ^[[A. This is not very helpful. I don't get this when accessing another server. Is this a setting the server makes, rather than the accessing client?

    Try checking the TERMINFO environment variable (or "infocmp | head -n 2") on both machines and see what they return.

    Barrakketh on
    Rollers are red, chargers are blue....omae wa mou shindeiru
  • Options
    bowenbowen How you doin'? Registered User regular
    edited April 2010
    This is usually the shell/server being responsible for this.

    Do a google for "up arrow command history (shell)" and see if you get anything that'll help you.

    bowen on
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Options
    MalkorMalkor Registered User regular
    edited April 2010
    Is '!!' universal?

    That should at least give you the last commmand.

    Malkor on
    14271f3c-c765-4e74-92b1-49d7612675f2.jpg
  • Options
    DedianDedian Registered User regular
    edited April 2010
    I think '!!' is a csh (or related) shell thing. ksh has 'r' for similar effect

    Dedian on
  • Options
    ÆthelredÆthelred Registered User regular
    edited April 2010
    !! executes the last command, which is useful but not always what you want.
    Madpanda wrote: »
    Do you have different keyboard settings per host? In putty go to Terminal->Keyboard and see if anything is different from the problem host compared to your default settings.

    I thought this would have some effect, but it doesn't.
    Barrakketh wrote: »
    Æthelred wrote: »
    Hopefully someone here will know what's up with this:

    I'm using putty to access a server via SSH. When I press 'up' on the keyboard, I expect to get back the line I previously entered. I don't - instead, I get ^[[A. This is not very helpful. I don't get this when accessing another server. Is this a setting the server makes, rather than the accessing client?

    Try checking the TERMINFO environment variable (or "infocmp | head -n 2") on both machines and see what they return.
    cs3% infocmp | head -n 2
    #       Reconstructed via infocmp from file: /usr/share/lib/terminfo/x/xterm
    xterm|vs100|xterm terminal emulator,
    

    Zese words, they mean nothing to me.

    Æthelred on
    pokes: 1505 8032 8399
  • Options
    BarrakkethBarrakketh Registered User regular
    edited April 2010
    Is that the same output on both the machine that is giving you problems and the one that works fine?

    Barrakketh on
    Rollers are red, chargers are blue....omae wa mou shindeiru
  • Options
    ÆthelredÆthelred Registered User regular
    edited April 2010
    Ah no; that's the un-fine one; this is the fine one:
    #       Reconstructed via infocmp from file: /usr/share/terminfo/x/xterm
    xterm|xterm terminal emulator (X Window System),
    

    I've also realised now that this means the left and right arrows don't work either. I get ^[[D and ^[[C instead of the cursor moving.

    Æthelred on
    pokes: 1505 8032 8399
  • Options
    EndEnd Registered User regular
    edited April 2010
    It's probably a server side issue. In putty you can configure up/down/etc to send a different sequence of characters, but the other end still has to interpret them.

    What operating system is the server running? What is your login shell?

    End on
    I wish that someway, somehow, that I could save every one of us
    zaleiria-by-lexxy-sig.jpg
  • Options
    vonPoonBurGervonPoonBurGer Registered User regular
    edited April 2010
    This has nothing to do with your terminal session, and therefore nothing to do with the client you're using (PuTTY, ssh, whatever). It's strictly an issue with the shell on the remote system. If you were logged in to a local terminal (i.e. using local keyboard and monitor) you'd probably encounter the same problem. This command should tell you what shell you're using on each system:
    echo $SHELL
    

    Since !! works, I'm pretty certain you're using either csh or tcsh, in which case you want to follow the directions here. Note that you still won't have the up-arrow functionality you're used to on the other server, where your shell is almost certainly bash. You'll have a bunch of less-slick but functionally-equivalent abilities.

    vonPoonBurGer on
    Xbox Live:vonPoon | PSN: vonPoon | Steam: vonPoonBurGer
  • Options
    BarrakkethBarrakketh Registered User regular
    edited April 2010
    Æthelred wrote: »
    Ah no; that's the un-fine one; this is the fine one:
    #       Reconstructed via infocmp from file: /usr/share/terminfo/x/xterm
    xterm|xterm terminal emulator (X Window System),
    

    I've also realised now that this means the left and right arrows don't work either. I get ^[[D and ^[[C instead of the cursor moving.

    Try copying the /usr/share/terminfo/x/xterm file from the machine that works to ~/.terminfo/x/xterm on the problematic machine and see if it works after re-connecting.

    Barrakketh on
    Rollers are red, chargers are blue....omae wa mou shindeiru
  • Options
    bowenbowen How you doin'? Registered User regular
    edited April 2010
    This has nothing to do with your terminal session, and therefore nothing to do with the client you're using (PuTTY, ssh, whatever). It's strictly an issue with the shell on the remote system. If you were logged in to a local terminal (i.e. using local keyboard and monitor) you'd probably encounter the same problem. This command should tell you what shell you're using on each system:
    echo $SHELL
    

    Since !! works, I'm pretty certain you're using either csh or tcsh, in which case you want to follow the directions here. Note that you still won't have the up-arrow functionality you're used to on the other server, where your shell is almost certainly bash. You'll have a bunch of less-slick but functionally-equivalent abilities.

    If I had to guess, I'd say csh.

    Though, !! is supported by bash, at least on ubuntu.

    bowen on
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Options
    ÆthelredÆthelred Registered User regular
    edited April 2010
    Oh I see, so I'm not actually using SSH at all! That will explain why the commands I'm used to don't work..

    I don't actually have much write access to this server, so I'll have to suck it up and learn the CSH commands. Why on earth don't they have left and right set up to navigate through text on the command line though?

    Æthelred on
    pokes: 1505 8032 8399
  • Options
    BarrakkethBarrakketh Registered User regular
    edited April 2010
    Æthelred wrote: »
    Oh I see, so I'm not actually using SSH at all! That will explain why the commands I'm used to don't work..

    I don't actually have much write access to this server, so I'll have to suck it up and learn the CSH commands. Why on earth don't they have left and right set up to navigate through text on the command line though?

    You're using SSH, but it's essentially just a transport protocol. You're still using a specific shell on the remote system, and putty (your terminal emulator) accepts the same control sequences as xterm plus some extras.

    Anyway, I mentioned copying it to your home directory on the misbehaving machine (most people have write access there), but would you mind copying/pasting the full output of "infocmp" from both machines? I might test it myself later (sorta busy right now), but I want to do a comparison between the two. terminfo is used to determine what control sequences a terminal emulator will accept, and I think those two differ in more ways than just the description.

    Barrakketh on
    Rollers are red, chargers are blue....omae wa mou shindeiru
  • Options
    ÆthelredÆthelred Registered User regular
    edited April 2010
    Sure, if you want to take a peek.

    The one that works the way I'm used to:
    #       Reconstructed via infocmp from file: /usr/share/terminfo/x/xterm
    xterm|xterm terminal emulator (X Window System),
            am, bce, km, mc5i, mir, msgr, npc, xenl,
            colors#8, cols#80, it#8, lines#24, pairs#64,
            acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
            bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, civis=\E[?25l,
            clear=\E[H\E[2J, cnorm=\E[?12l\E[?25h, cr=^M,
            csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
            cud=\E[%p1%dB, cud1=^J, cuf=\E[%p1%dC, cuf1=\E[C,
            cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
            cvvis=\E[?12;25h, dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM,
            dl1=\E[M, ech=\E[%p1%dX, ed=\E[J, el=\E[K, el1=\E[1K,
            flash=\E[?5h$<100/>\E[?5l, home=\E[H, hpa=\E[%i%p1%dG,
            ht=^I, hts=\EH, ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L,
            ind=^J, indn=\E[%p1%dS, invis=\E[8m,
            is2=\E[!p\E[?3;4l\E[4l\E>, kDC=\E[3;2~, kEND=\E[1;2F,
            kHOM=\E[1;2H, kIC=\E[2;2~, kLFT=\E[1;2D, kNXT=\E[6;2~,
            kPRV=\E[5;2~, kRIT=\E[1;2C, kb2=\EOE, kbs=\177, kcbt=\E[Z,
            kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,
            kdch1=\E[3~, kend=\EOF, kent=\EOM, kf1=\EOP, kf10=\E[21~,
            kf11=\E[23~, kf12=\E[24~, kf13=\EO2P, kf14=\EO2Q,
            kf15=\EO2R, kf16=\EO2S, kf17=\E[15;2~, kf18=\E[17;2~,
            kf19=\E[18;2~, kf2=\EOQ, kf20=\E[19;2~, kf21=\E[20;2~,
            kf22=\E[21;2~, kf23=\E[23;2~, kf24=\E[24;2~, kf25=\EO5P,
            kf26=\EO5Q, kf27=\EO5R, kf28=\EO5S, kf29=\E[15;5~,
            kf3=\EOR, kf30=\E[17;5~, kf31=\E[18;5~, kf32=\E[19;5~,
            kf33=\E[20;5~, kf34=\E[21;5~, kf35=\E[23;5~,
            kf36=\E[24;5~, kf37=\EO6P, kf38=\EO6Q, kf39=\EO6R,
            kf4=\EOS, kf40=\EO6S, kf41=\E[15;6~, kf42=\E[17;6~,
            kf43=\E[18;6~, kf44=\E[19;6~, kf45=\E[20;6~,
            kf46=\E[21;6~, kf47=\E[23;6~, kf48=\E[24;6~, kf49=\EO3P,
            kf5=\E[15~, kf50=\EO3Q, kf51=\EO3R, kf52=\EO3S,
            kf53=\E[15;3~, kf54=\E[17;3~, kf55=\E[18;3~,
            kf56=\E[19;3~, kf57=\E[20;3~, kf58=\E[21;3~,
            kf59=\E[23;3~, kf6=\E[17~, kf60=\E[24;3~, kf61=\EO4P,
            kf62=\EO4Q, kf63=\EO4R, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~,
            khome=\EOH, kich1=\E[2~, kind=\E[1;2B, kmous=\E[M,
            knp=\E[6~, kpp=\E[5~, kri=\E[1;2A, mc0=\E[i, mc4=\E[4i,
            mc5=\E[5i, meml=\El, memu=\Em, op=\E[39;49m, rc=\E8,
            rev=\E[7m, ri=\EM, rin=\E[%p1%dT, rmacs=\E(B, rmam=\E[?7l,
            rmcup=\E[?1049l, rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[27m,
            rmul=\E[24m, rs1=\Ec, rs2=\E[!p\E[?3;4l\E[4l\E>, sc=\E7,
            setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
            setb=\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
            setf=\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
            sgr=%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m,
            sgr0=\E(B\E[m, smacs=\E(0, smam=\E[?7h, smcup=\E[?1049h,
            smir=\E[4h, smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m,
            tbc=\E[3g, u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?1;2c, u9=\E[c,
            vpa=\E[%i%p1%dd,
    


    And the other:
    #       Reconstructed via infocmp from file: /usr/share/lib/terminfo/x/xterm
    xterm|vs100|xterm terminal emulator,
            am, km, mir, msgr, xenl,
            cols#80, it#8, lines#65,
            acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
            bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[H\E[2J,
            cr=\r, csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=\b,
            cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
            cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
            dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M,
            ed=\E[J, el=\E[K, el1=\E[1K$<3>, enacs=\E(B\E)0,
            home=\E[H, ht=\t, hts=\EH, ich=\E[%p1%d@, ich1=\E[@,
            il=\E[%p1%dL, il1=\E[L, ind=\n, ka1=\EOq, ka3=\EOs,
            kb2=\EOr, kbs=\b, kc1=\EOp, kc3=\EOn, kcub1=\EOD,
            kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kent=\EOM,
            kf0=\E[21~, kf1=\E[11~, kf10=\EOx, kf2=\E[12~,
            kf3=\E[13~, kf4=\E[14~, kf5=\E[15~, kf6=\E[17~,
            kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, rc=\E8, rev=\E[7m,
            ri=\EM, rmacs=^O, rmkx=\E[?1l\E>, rmso=\E[m,
            rmul=\E[m,
            rs1=\E>\E[1;3;4;5;6l\E[?7h\E[m\E[r\E[2J\E[H, rs2=@,
            sc=\E7,
            sgr=\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;m%?%p9%t^N%e^O%;,
            sgr0=\E[m, smacs=^N, smkx=\E[?1h\E=, smso=\E[7m,
            smul=\E[4m, tbc=\E[3g,
    

    Æthelred on
    pokes: 1505 8032 8399
  • Options
    BarrakkethBarrakketh Registered User regular
    edited April 2010
    Well, those are obviously different, and most of the same commands are implemented differently. In fact, only one "command" is the same in both files (I sorted them with sort and used "comm -12" to only show the lines common to both).

    I'll repeat my earlier suggestion: Try copying the /usr/share/terminfo/x/xterm file from the machine that works to ~/.terminfo/x/xterm on the problematic machine (in your home directory) and see if it works after re-connecting. The home directory entry should be used first and things should work as expected.

    Barrakketh on
    Rollers are red, chargers are blue....omae wa mou shindeiru
  • Options
    Gilbert0Gilbert0 North of SeattleRegistered User regular
    edited May 2010
    Try this

    previous line: ESC and then K, further history keep hitting K

    To edit that line is L to move right, H to move right and then I to start an insert (like VI)

    Gilbert0 on
  • Options
    McCow42McCow42 Registered User regular
    edited May 2010
    Usually you can check the valid shells the server supports by doing the following:
    cat /etc/shells
    

    With this handy list you can change shells to any listed in the result set by using chsh.

    For example: to change to bash on my machine.
    chsh -s /bin/bash
    

    McCow42 on
Sign In or Register to comment.