[arch-general] Impossible redirect console buffer to log

Maykel Franco maykeldebian at gmail.com
Fri Mar 1 21:27:20 UTC 2019


El vie., 1 mar. 2019 a las 21:49, Chris Billington
(<chrisjbillington at gmail.com>) escribió:
>
> The output of the script command can contain all sorts of control characters and ANSI escape sequences since it is exactly what is being written to the terminal.
>
> Incidentally, I have written a Python function for cleaning up such output (solely used to document my Arch linux installation):
>
> https://bitbucket.org/cbillington/arch_install/src/default/arch_install.py#lines-58
>
> It doesn't just remove the control characters (and ANSI escape sequences), it processes backspace characters and carriage returns etc to result in what you would have seen on your screen. It is not comprehensive but does a pretty good job. So you might want to postprocess your logs with that or similar.
>
> -Chris
>
>
> On Fri, Mar 1, 2019 at 3:41 PM Maykel Franco <maykeldebian at gmail.com> wrote:
>>
>> El vie., 1 mar. 2019 a las 21:32, Chris Billington
>> (<chrisjbillington at gmail.com>) escribió:
>> >
>> > The 'flush' option could help with that:
>> > [bilbo:~]$ script -h | grep flush
>> >  -f, --flush                   run flush after each write
>> >
>> > So, something like
>> >
>> > script -f -c '/usr/local/bin/cccam -d' mylogfile.log
>> >
>> > I would want to get to the bottom of why this binary does not play well with normal tools, but if you just need things working, it looks like you might have something workable with 'script'.
>> >
>> > -Chris
>> >
>> > On Fri, Mar 1, 2019 at 3:27 PM Maykel Franco <maykeldebian at gmail.com> wrote:
>> >>
>> >> El vie., 1 mar. 2019 a las 20:08, Chris Billington
>> >> (<chrisjbillington at gmail.com>) escribió:
>> >> >
>> >> > This is pretty strange.
>> >> >
>> >> > As for the script command, it can be passed the command to run, but I am guessing it will have the same symptoms as with 'unbuffer':
>> >> >
>> >> > [bilbo:~]$ script -c 'echo hello' mylogfile.log
>> >> > Script started, file is mylogfile.log
>> >> > hello
>> >> > Script done, file is mylogfile.log
>> >> > [bilbo:~]$ cat mylogfile.log
>> >> > Script started on 2019-03-01 14:05:28-05:00 [TERM="xterm-256color" TTY="/dev/pts/0" COLUMNS="137" LINES="24"]
>> >> > hello
>> >> >
>> >> > Script done on 2019-03-01 14:05:28-05:00 [COMMAND_EXIT_CODE="0"]
>> >> >
>> >> > On Fri, Mar 1, 2019 at 1:40 PM Maykel Franco via arch-general <arch-general at archlinux.org> wrote:
>> >> >>
>> >> >> El vie., 1 mar. 2019 a las 19:30, Ralph Corderoy
>> >> >> (<ralph at inputplus.co.uk>) escribió:
>> >> >> >
>> >> >> > Hi Maykel,
>> >> >> >
>> >> >> > > > command &> out
>> >> >> > >
>> >> >> > > Not works... I probe all combinations:
>> >> >> > >
>> >> >> > > > file redirects stdout to file
>> >> >> > > 1> file redirects stdout to file
>> >> >> > > 2> file redirects stderr to file
>> >> >> > > &> file redirects stdout and stderr to file
>> >> >> >
>> >> >> > Can you show us one complete command with `&>' in case there's something
>> >> >> > else wrong?
>> >> >> >
>> >> >> > Otherwise, `LC_ALL=C strace -ff -o st /usr/local/bin/CCcam -d'
>> >> >> > will capture the write(2)s or similar and you can see what file
>> >> >> > descriptors its writing to and work backwards to see how that was
>> >> >> > obtained, e.g. by opening /dev/tty.
>> >> >> >
>> >> >> > --
>> >> >> > Cheers, Ralph.
>> >> >>
>> >> >> Nothing happens, it closes and the process does not start
>> >> >>
>> >> >> root at arch:~# LC_ALL=C strace -ff -o st /usr/local/bin/cccam -d
>> >> >> root at arch:~#
>> >> >> root at arch:~#
>> >>
>> >> ok, ask you for command script, ok:
>> >>
>> >> script -c '/usr/local/bin/cccam -d' mylogfile.log
>> >>
>> >> This is works, but only write to file when stop script with ctrl + c
>> >>
>> >>
>> >> ~# cat mylogfile.log
>> >> Script started on Fri Mar  1 21:24:35 2019
>> >> 21:24:35.913 CCcam:
>> >> ======================================================================
>> >> 21:24:35.913 CCcam: starting CCcam 2.1.3 compiled on Nov 14 2009 at 00:47:12
>> >> 21:24:35.913 CCcam:
>> >> ======================================================================
>> >> 21:24:35.913 CCcam: online using nodeId 95ced5a4a066a2b2
>> >> 21:24:35.931 CCcam: create 1 cam device(s)
>> >> 21:24:35.935 CCcam: readKeyfile: cannot open /var/keys/SoftCam.Key or not found
>> >> 21:24:35.936 CCcam: readKeyfile: cannot open /var/keys/AutoRoll.Key or not found
>> >> 21:24:35.936 CCcam: static cw not found or bad
>> >> 21:24:35.943 CCcam: parsed 11522 entries from /var/etc/CCcam.prio
>> >> 21:24:35.943 CCcam: added 1005 provider names from /var/etc/CCcam.providers
>> >> 21:24:36.035 CCcam: added 11097 channel names from /var/etc/CCcam.channelinfo
>> >> 21:24:36.035 CCcam: server started on port 47015
>> >>
>> >>
>> >> The script download from:
>> >>
>> >> https://github.com/ryanfox1985/docker-cccam/blob/master/CCcam.x86_64
>> >>
>> >> Thanks.
>>
>> wow, it works! Many thanks.
>>
>> Now only remove ^M character from log files in buffer time but this not working:
>>
>>
>> script -f -c '/usr/local/bin/cccam -d' mylogfile.log | sed 's/^M//g'
>>
>> If you want to try it because it does not work with the normal tools
>> you can download it here
>>
>> https://github.com/ryanfox1985/docker-cccam/blob/master/CCcam.x86_64
>>
>> Many thanks again for all.

ok, thanks again.


More information about the arch-general mailing list