I want to use GNU screen to run a single command in detached mode over serial console and save it's output to the log file on the host where screen is running. Basically, non-interactive equivalent of the following actions:
screen /dev/ttyUSB0 115200 # connect to serial console "/dev/ttyUSB0" using speed "115200"
ctrl+a H # start logging
some command
ctrl+a k y # quit
I know how to run a single command in detached mode in the current shell:
screen -d -m -L some command
# output is saved to screenlog.0
But I don't understand how to do the same thing while also attaching to a serial console.