The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,046 other followers

Archive for the ‘OS X 10.10 Yosemite’ Category

Mac OS X / macOS / …: quit screen or window when using it for a serial port

Posted by jpluimers on 2020/03/06

I wrote a bit on using screen from my Mac in The woods and trees of OpenSuSE on single-board computers – image abbreviations – and getting it installed using OS X.

The coverage was way too brief and also buried in large post.

Today, I want to focus on some things related to properly terminating a a screen window, session or screen by itself from a Mac which somehow is one of the harder things for me to do.

I’m talking about sessions and windows, because screen is a terminal multiplexer, which can also put a serial link in a window on a session. So screen is not “just” a serial console terminal application by itself.

Part of being hard is probably that even on for instance 10.12 Sierra, Apple ships a fairly old version: screen --version returns Screen version 4.00.03 (FAU) 23-Oct-06 whereas after 2014 (before that, screen development was pretty stalled) many new versions appeared: [WayBack] screen.git.

It makes it less hard that it hardly reproduces, and seems to reproduce less with the screen version I installed through homebrew: Screen version 4.06.02 (GNU) 23-Oct-17.

Time to make some notes so I can hopefully amend them later with solutions.

The screen magic key

When screen gives you a session to a terminal, all but one key are being routed through on a 1-on-1 base except for a “magic” key combination: Ctrla (which the documentation abbreviates as C-a).

Following the Ctrla combination, you can type a character (sometimes that needs Ctrl too) for a lot screen functionality (for a start, see the “Getting help” below).

Listing existing screen sessions and windows

Each screen process has one session

You list screen sessions from the command-line. I usually combine the latter with getting a process list as well using this command because the process list will show you parameters passed to screen:

ps -ax | grep screen && screen -list

which gets you output like this:

31992 ttys019    0:00.01 screen
29040 ttys020    0:00.04 screen /dev/cu.usbserial 115200
31898 ttys021    0:00.01 screen
32503 ttys025    0:00.00 grep screen
There are screens on:
    29041.ttys020.RMBPro1TBJWP  (Attached)
    31899.ttys021.RMBPro1TBJWP  (Attached)
    31993.ttys019.RMBPro1TBJWP  (Attached)
3 Sockets in /var/folders/zr/dsp77fhs6zq179n72lykjrjw0000gq/T/.screen.

Many people abbreviate screen -list as screen -ls, but I like descriptive commands over cryptic ones.

What you see is that:

  • there are three screen sessions of which one is using a USB serial device.
  • there is one session per screen session

Windows are within sessions

From within each session, you can use the Ctrl* combination to list the Windows. For the both non-serial sessions – looked like this on my machine:

term-type   size         user interface           window
---------- ------- ---------- ----------------- ----------
xterm-256c  84x28     jeroenp@/dev/ttys019        0(bash)       rwx

and

term-type   size         user interface           window
---------- ------- ---------- ----------------- ----------
xterm-256c  84x28     jeroenp@/dev/ttys021        1(bash)       rwx

The first was for session 31899.ttys021.RMBPro1TBJWP, the second for 31993.ttys019.RMBPro1TBJWP.

Attaching (or re-attaching) to an existing session

The -x parameter can attach to both an Attached or a Detached screen session. This allows for:

  • multiple Mac terminal tabs to see the same content
  • getting access to a detached session (because you – maybe by accident – closed terminal,  or detached the session)

Detached sessions keep their windows and the commands running in those windows. This allows you to have long-running scripts starting from the terminal but not terminated when the terminal closes.

So in my case, this command attaches to the second session not matter if it is attached or detached.

screen -x 31993.ttys019.RMBPro1TBJWP

Killing an existing window

When killing a window, all the processes in that window will be killed too.

Typing Ctrla followed by k or Ctrlk will kill the current window.

Killing a session with all windows

When killing a session, it will kill all the windows with all the processes in those windows.

Typing Ctrla followed by Ctrl\ will kill the current session with all the windows in it. On some Linux systems, you can replace Ctrl\ with just \.

I’ve not run into dead sessions yet, but if I do, I should try the -wipe command line option as shown in [WayBack] How to kill a dead screen session? – Stack Overflow (which also shows this can fail if you run out of disk space, but then you have bigger issues).

TODO: Killing a session that seems attached but isn’t

I still need to research this further, as every now and then I run into this:

# ps -ax | grep -w screen && screen -list
29040 ?? 0:00.04 screen /dev/cu.usbserial 115200
35724 ttys025 0:00.00 grep -w screen
There is a screen on:
 29041.ttys020.RMBPro1TBJWP (Attached)
1 Socket in /var/folders/zr/dsp77fhs6zq179n72lykjrjw0000gq/T/.screen.

Wiping it fails:

# screen -wipe 29041.ttys020.RMBPro1TBJWP
There is a screen on:
 29041.ttys020.RMBPro1TBJWP (Attached)
1 Socket in /var/folders/zr/dsp77fhs6zq179n72lykjrjw0000gq/T/.screen.

Attaching however times out:

# screen -x 29041.ttys020.RMBPro1TBJWP

For now, the only option is to reboot my system.

I’ve seen this happening mostly with cables that present themselves as prolific PL2303HX chipset.

So I will get some TTL debug cables based on other chipsets.

These posts will help finding about the available serial cables:

Getting help

It is daunting, but the man screen page [WayBack] has a truckload of information, for instance on the command-line options, key bindings and much more.

If you like on-line lists of tips more, then follow these:

The man page will get you most of that information:

Start screen

Screen version 4.00.03 (FAU) 23-Oct-06

Copyright (c) 1993-2002 Juergen Weigert, Michael Schroeder
Copyright (c) 1987 Oliver Laumann

This program is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation; either version 2, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this
program (see the file COPYING); if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

Send bugreports, fixes, enhancements, t-shirts, money, beer & pizza to
screen@uni-erlangen.de


                          [Press Space or Return to end.]

Here you can press Ctrl-A followed by : to get a prompt where you can type help:

[Press Space or Return to end.]
:help

There you get one or two (depending on your terminal size) pages of help:

                         Screen key bindings, page 1 of 2.

                         Command key:  ^A   Literal ^A:  a

   break       ^B b          license     ,             reset       Z         
   clear       C             lockscreen  ^X x          screen      ^C c      
   colon       :             log         H             select      '         
   copy        ^[ [          meta        a             silence     _         
   detach      ^D d          monitor     M             split       S         
   digraph     ^V            next        ^@ ^N sp n    suspend     ^Z z      
   displays    *             number      N             time        ^T t      
   dumptermcap .             only        Q             title       A         
   fit         F             other       ^A            vbell       ^G        
   flow        ^F f          pow_break   B             version     v         
   focus       ^I            pow_detach  D             width       W         
   hardcopy    h             prev        ^H ^P p ^?    windows     ^W w      
   help        ?             quit        ^\            wrap        ^R r      
   history     { }           readbuf     < writebuf >         
   info        i             redisplay   ^L l          xoff        ^S s      
   kill        ^K k          remove      X             xon         ^Q q      
   lastmsg     ^M m          removebuf   =         

                    [Press Space for next page; Return to end.]

followed by:

                         Screen key bindings, page 2 of 2.

^]  paste .
"   windowlist -b
-   select -
0   select 0
1   select 1
2   select 2
3   select 3
4   select 4
5   select 5
6   select 6
7   select 7
8   select 8
9   select 9
]   paste .






                          [Press Space or Return to end.]

–jeroen

Partially based on: [WayBack] terminate screen monitoring serial port – Unix & Linux Stack Exchange.

Posted in *nix, *nix-tools, Apple, Mac, Mac OS X / OS X / MacOS, MacBook, MacBook Retina, MacBook-Air, MacBook-Pro, MacMini, macOS 10.12 Sierra, macOS 10.13 High Sierra, OS X 10.10 Yosemite, OS X 10.11 El Capitan, Power User, screen | Leave a Comment »

Apple Mac OS X / OS X / macOS versions and history graphs – Wikipedia

Posted by jpluimers on 2020/01/03

Based on [WayBackmacOS – Wikipedia and follow-up of OS X – the versions and their names – as I always forget them and osx – How to find out Mac OS X version from Terminal? (via: Super User)

Release history (with release dates):

The graph with Apple Mac OS X / OS X / Mac OS versions cannot do without a graph showing the BSD and Unix inheritance.

Graph origins:

More complete Mac OS X / OS X / Mac OS and Unix timelines are below from macOS version history – Wikipedia.

–jeroen

Read the rest of this entry »

Posted in Apple, Mac OS X / OS X / MacOS, Mac OS X 10.4 Tiger, Mac OS X 10.5 Leopard, Mac OS X 10.6 Snow Leopard, Mac OS X 10.7 Lion, macOS 10.12 Sierra, macOS 10.13 High Sierra, OS X 10.10 Yosemite, OS X 10.11 El Capitan, OS X 10.8 Mountain Lion, OS X 10.9 Mavericks, Power User | Leave a Comment »

Apple Mac OS X / MacOS: Dock keeps moving between monitors | Official Apple Support Communities

Posted by jpluimers on 2019/12/30

My Dock kept moving to another monitor every now and then.

This actually seems to be a feature but got me a while to find out what it does at [WayBackDock keeps moving between monitors | Official Apple Support Communities:

If you move the mouse to another window and pull it down to very bottom of the screen and hold it there, the dock moves over. To move it back, move the mouse pointer to the screen you want it on and hold the pointer at the very bottom of the screen.

This bites you when an application has features (like tools) at the very bottom of a window.

–jeroen

Posted in Apple, iMac, Mac, Mac OS X / OS X / MacOS, MacBook, MacBook Retina, MacBook-Air, MacBook-Pro, MacMini, macOS 10.12 Sierra, OS X 10.10 Yosemite, OS X 10.11 El Capitan, OS X 10.9 Mavericks, Power User | Leave a Comment »

Setting Up a New Mac: Should You Migrate or Do a Clean Installation? | The Mac Security Blog

Posted by jpluimers on 2019/10/07

Interesting read: [WayBackSetting Up a New Mac: Should You Migrate or Do a Clean Installation? | The Mac Security Blog

–jeroen

Posted in Apple, iMac, Mac, Mac OS X / OS X / MacOS, Mac OS X 10.4 Tiger, Mac OS X 10.5 Leopard, Mac OS X 10.6 Snow Leopard, Mac OS X 10.7 Lion, MacBook, MacBook Retina, MacBook-Air, MacBook-Pro, MacMini, macOS 10.12 Sierra, OS X 10.10 Yosemite, OS X 10.11 El Capitan, OS X 10.8 Mountain Lion, OS X 10.9 Mavericks, Power User | Leave a Comment »

logging – Where is “/var/log/messages” on mac-osx? – Server Fault

Posted by jpluimers on 2019/07/29

logging – Where is “/var/log/messages” on mac-osx? – Server Fault

TL;DR: because most of it is in /var/log/system.log which is configured in /etc/asl.conf, but the documentation example about syslog.conf never got updated.

Long read

The example in syslog.conf is wrong at WayBack: Mac OS X Manual Page For syslog.conf(5) and man syslog.conf:

EXAMPLES
     A configuration file might appear as follows:
...
     # Log anything (except mail) of level info or higher.
     # Don't log private authentication messages!
     *.info;mail.none;authpriv.none          /var/log/messages
...
FILES
     /etc/syslog.conf  The syslogd(8) configuration file.

It still is when writing this [WayBack]syslog.conf(5) Mac OS X Manual Page, so you have to look at /etc/syslog.conf on a live system:

# Note that flat file logs are now configured in /etc/asl.conf

install.*                       @127.0.0.1:32376

which means the actual configuration is in /etc/asl.conf:

# Rules for /var/log/system.log
> system.log mode=0640 format=bsd rotate=seq compress file_max=5M all_max=50M
? [= Sender kernel] file system.log
? [<= Level notice] file system.log
? [= Facility auth] [<= Level info] file system.log
? [= Facility authpriv] [<= Level info] file system.log

Documentation at [WayBack] asl.conf(5) Mac OS X Manual Page indicates this:

NAME
     asl.conf -- configuration file for syslogd(8) and aslmanager(8)

DESCRIPTION
     The syslogd(8) server reads the /etc/asl.conf file at startup, and re-reads the file when it receives a HUP signal.  The aslmanager(8) daemon reads the file when it starts.  See the
     ASLMANAGER PARAMETER SETTINGS section for details on aslmanager-specific parameters.

Source

Based on [WayBacklogging – Where is “/var/log/messages” on mac-osx? – Server Fault:

Q:

When you read the man pages on Mac OS X, there are references to /var/log/messages, but if you look for the file, it doesn’t exist:

$ ls -l /var/log/messages
ls: /var/log/messages: No such file or directory

A:

2009 era: If you look at the actual /etc/syslog.conf instead of the man page, you see *.notice;authpriv,remoteauth,ftp,install.none;kern.debug;mai‌​l.crit /var/log/system.log

–jeroen

Posted in Apple, Mac OS X / OS X / MacOS, Mac OS X 10.4 Tiger, Mac OS X 10.5 Leopard, Mac OS X 10.6 Snow Leopard, Mac OS X 10.7 Lion, macOS 10.12 Sierra, OS X 10.10 Yosemite, OS X 10.11 El Capitan, OS X 10.8 Mountain Lion, OS X 10.9 Mavericks, Power User | Leave a Comment »

 
%d bloggers like this: