terminal - Python and Termlib: How do I delete the line after tn.write('wrongstring')? -


i simulate user interaction remote terminal short-cut delete line terminal emulator ctrl+u.

assume telnet session up:

host='1.1.1.1' tn = telnetlib.telnet(host) tn.write('wrongstring') 

now need delete line. how do that? how send ctrl+u terminal via tn.write?

edit: did trick

tn.write('\x15') 

not sure why ascii sequence suggested below did not work.

unless you're providing input remote shell interpreter, sending controlu not help.

if writing terminal accepts "ansi escapes", knows how erase current line. referring xterm control sequences:

csi ps k  erase in line (el).             ps = 0  -> erase right (default).             ps = 1  -> erase left.             ps = 2  -> erase all. 

you erase whole line writing "\033[2k". not move cursor. move cursor left margin (on many terminals)

csi ps g  cursor character absolute  [column] (default = [row,1]) (cha). 

by writing "\033[g". finally, if had remove previous line, move cursor cpl or vpa control sequence (which less implemented).


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -