Python Forum
this thing i have created for Linux rocks!
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
this thing i have created for Linux rocks!
#1
this thing i have created for Linux rocks! at least for me, it does. i use the command line quite heavily. even though i run my laptop in graphical mode under Ubuntu (16.04.3 LTS) Unity. i still have lots of terminal windows open (more than Firefox) and have made a lot of use of the screen command. i have even created an ssh script that lets me specify a screen session to connect to or create (ssh username+screenname@host+port).

the thing i have created is a set of Python scripts to front end the screen command in a few ways. the first is sbg which creates an idle (waiting for input) background session with my shell (bash) running. it includes 2 options (cols and rows) to set the virtual display size. the second is scn which connects to a background session just like the screen command does with the right options, but with less typing. the third is sin which lets me enter input (typed on the command line as arguments) to existing background sessions. the fourth is sls which lists the existing screen sessions. it is just a convenient way to do "screen -ls" the fifth is sss which takes a snapshot of the background session virtual display and outputs it. sss and sin are used the most. i use them most heavily on remote hosts and cloud instances because i don't keep so many ssh sessions open.

i can push heavier time consuming commands into background sessions so easily now that almost everything i expect to run longer than 20 seconds and don't need to immediately see the output from, i do through one of these background sessions with that sin command. it nicely inserts spaces between arguments and appends a carriage return at the end. an option exists to turn off the appended carriage return. it interprets sequences like \r and \t and inputs the corresponding single control character. it supports a larger set of these than the Python interpreter does for Python source code (so i am not using the interpreter to fudge any of this to be pythonic). it also supports carat sequences like ^c and ^[. ^i is a tab just like \t. ^m is a carriage return just like \r. it also interprets codes in octal like \033 and \o033 which are escape just like \e. and it interprets sequences in other bases: 10: \d255 16: \xff 4: \q3333 (think Quad) and 2: \y11111111 (think binarY). a better list of these is in the source code comments.

i've probably used these commands a couple hundred times, just tonight (past 3 AM now). i am still tweaking these and catching little bugs. i will likely release these, and separate functions to do the control character sequence conversion, sometime this month. other commands are planned to allow raw output to stdout, instead of to a background session. i am also looking around for how to make this into a codec, e.g. decode (\t to tab) and encode (tab to \t).
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
I am not familiar with screen and can't test it. I am using tmux sometimes.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#3
Ive never used screen so not sure about it. I always use tmux. Which allows by default to split windows and more, as well as leave a session running in the background.
Recommended Tutorials:
Reply
#4
i have never used tmux. if it has a means to stuff input into a background session and a means to view or acquire the current screen contents without reconnecting, then it is likely possible to make versions of these scripts around tmux.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  a one line thing Skaperen 2 2,481 Feb-09-2018, 02:12 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020