Re: [DNG] Viewing file content (was Re: system administration of non-systemd distros and releases)

2021-11-28 Thread Hendrik Boom
On Fri, Nov 26, 2021 at 09:23:05PM -0500, Steve Litt wrote:
> Olaf Meeuwissen said on Fri, 26 Nov 2021 18:40:37 +0900
> 
> >Hi,
> >
> >Steve Litt writes:
> >
> >> What could possibly be easier than vim /var/log/messages, or
> >> vi /var/log/messages, or emacs /var/log/messages, or
> >> nano /var/log/messages? And notice with the old way, you have a
> >> choice, rather than having to look at log output with the vendor's
> >> proprietary tool.  
> >
> >Maybe I'm peculiar but I always find it absolutely, totally
> >jaw-dropping when people use text *editors* to *look* at file content.
> > Makes my toes curl up and blood curdle.
> 
> You're right. Use less or some other *viewer*.

For things like log output, which must be kept unchanged, a read-only 
viewer would suffice.  Or a read-only editor.  Editors sometimes have 
texual search mechanisms that are better than viewers.  And if you use 
one editor a *lot*, its commands are muscle memory.

For things tat you primarily want to read, but rarely fix a typo or 
such, you can open a text editor in read-only mode, protecting you from 
inadvertent edits.

-- hendrik

> 
> SteveT
> 
> Steve Litt 
> Spring 2021 featured book: Troubleshooting Techniques of the Successful
> Technologist http://www.troubleshooters.com/techniques
> ___
> Dng mailing list
> Dng@lists.dyne.org
> https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] Viewing file content (was Re: system administration of non-systemd distros and releases)

2021-11-27 Thread Olaf Meeuwissen via Dng
Hi,

wirelessduck--- via Dng writes:

>> On 27 Nov 2021, at 14:24, Olaf Meeuwissen  wrote:
>>
>> Looking at the lesspipe manual page[1] (don't have less installed ;-),
>> it seems that it doesn't support on-the-fly encoding switching but as
>> far as dealing with compressed files, I guess there is no or not much
>> difference.
>>
>> [1]: https://manpages.debian.org/bullseye/less/lesspipe.1.en.html
>
> Ahh ok. I’ve never had to deal with alternate encodings. If I ever
> needed that I would probably just alias less to lv, assuming the UI is
> similar enough. Muscle memory is hard to overcome sometimes.

ACK.  First thing I do on Alpine and RPM distros is add an alias for
pager to my ~/.profile.

BTW, for those interested in or already using lv, you may want to add a
.lv file with

  -c

to make it work better with ANSI escape codes (lest they are mistaken
for part of text in some encoding).

Hope this helps.
--
Olaf Meeuwissen, LPIC-2FSF Associate Member since 2004-01-27
 GnuPG key: F84A2DD9/B3C0 2F47 EA19 64F4 9F13  F43E B8A4 A88A F84A 2DD9
 Support Free Softwarehttps://my.fsf.org/donate
 Join the Free Software Foundation  https://my.fsf.org/join
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] Viewing file content (was Re: system administration of non-systemd distros and releases)

2021-11-27 Thread wirelessduck--- via Dng


> On 27 Nov 2021, at 14:24, Olaf Meeuwissen  wrote:
> 
> Looking at the lesspipe manual page[1] (don't have less installed ;-),
> it seems that it doesn't support on-the-fly encoding switching but as
> far as dealing with compressed files, I guess there is no or not much
> difference.
> 
> [1]: https://manpages.debian.org/bullseye/less/lesspipe.1.en.html

Ahh ok. I’ve never had to deal with alternate encodings. If I ever needed that 
I would probably just alias less to lv, assuming the UI is similar enough. 
Muscle memory is hard to overcome sometimes.
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] Viewing file content (was Re: system administration of non-systemd distros and releases)

2021-11-26 Thread Olaf Meeuwissen via Dng
Hi,

wirelessduck--- via Dng writes:

>> On 26 Nov 2021, at 20:40, Olaf Meeuwissen via Dng  wrote:
>>
>> # On my own machines `lv` makes a fine `pager` for me.  On the fly
>> # decompression and handling of many different encodings.  So for me,
>> # it's just
>> #
>> #  pager /var/log/syslog.2.gz
>> #
>> # without any `zmore` or `zcat` piping.  There is still no zpager :-/
>> # but with `lv` I don't really need one.
>
> Does lv provide anything extra or different to enabling lesspipe.sh in bashrc?

The main reason for me to use lv was a need to view text files encoded
in one of Shift-JIS, EUC-JP or UTF-8.  With lv, most of the time it
guesses the encoding right and if not you can loop through a bunch of
supported encodings with `t`.

# I've also had to deal with files with mixed encodings :-0, part
# Shift-JIS, part ISO-8859-* and sometimes even a bit in one of the
# Chinese encodings.  Being able to toggle encoding for the current
# "page" on the fly makes it at least possible to see what's in the
# file.

Looking at the lesspipe manual page[1] (don't have less installed ;-),
it seems that it doesn't support on-the-fly encoding switching but as
far as dealing with compressed files, I guess there is no or not much
difference.

 [1]: https://manpages.debian.org/bullseye/less/lesspipe.1.en.html

Hope this helps,
--
Olaf Meeuwissen, LPIC-2FSF Associate Member since 2004-01-27
 GnuPG key: F84A2DD9/B3C0 2F47 EA19 64F4 9F13  F43E B8A4 A88A F84A 2DD9
 Support Free Softwarehttps://my.fsf.org/donate
 Join the Free Software Foundation  https://my.fsf.org/join
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] Viewing file content (was Re: system administration of non-systemd distros and releases)

2021-11-26 Thread Steve Litt
Olaf Meeuwissen said on Fri, 26 Nov 2021 18:40:37 +0900

>Hi,
>
>Steve Litt writes:
>
>> What could possibly be easier than vim /var/log/messages, or
>> vi /var/log/messages, or emacs /var/log/messages, or
>> nano /var/log/messages? And notice with the old way, you have a
>> choice, rather than having to look at log output with the vendor's
>> proprietary tool.  
>
>Maybe I'm peculiar but I always find it absolutely, totally
>jaw-dropping when people use text *editors* to *look* at file content.
> Makes my toes curl up and blood curdle.

You're right. Use less or some other *viewer*.

SteveT

Steve Litt 
Spring 2021 featured book: Troubleshooting Techniques of the Successful
Technologist http://www.troubleshooters.com/techniques
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] Viewing file content (was Re: system administration of non-systemd distros and releases)

2021-11-26 Thread wirelessduck--- via Dng


> On 26 Nov 2021, at 20:40, Olaf Meeuwissen via Dng  wrote:
> 
> # On my own machines `lv` makes a fine `pager` for me.  On the fly
> # decompression and handling of many different encodings.  So for me,
> # it's just
> #
> #  pager /var/log/syslog.2.gz
> #
> # without any `zmore` or `zcat` piping.  There is still no zpager :-/
> # but with `lv` I don't really need one.

Does lv provide anything extra or different to enabling lesspipe.sh in bashrc?
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] Viewing file content (was Re: system administration of non-systemd distros and releases)

2021-11-26 Thread Peter Duffy
Personally, if I want to look at a file without editing it, if it's
small, I'll use view - which gives me the vi interface with the file in
read-only mode. It means I get the same interface and facilities that I
use when actually editing files, and it's easy to remember and (usually)
automatic. If I'm examining logs, I normally use less: handles big files
well, and (to coin a phrase) has more functionality than "more". It also
has the brilliant ctrl-f feature to show updates to the log in real-time
(like "tail -f" but with the advantage that the "tailing" mode can be
entered and exited without losing access to the file).  

On Fri, 2021-11-26 at 18:40 +0900, Olaf Meeuwissen via Dng wrote:
> Hi,
> 
> Steve Litt writes:
> 
> > What could possibly be easier than vim /var/log/messages, or
> > vi /var/log/messages, or emacs /var/log/messages, or
> > nano /var/log/messages? And notice with the old way, you have a choice,
> > rather than having to look at log output with the vendor's proprietary
> > tool.
> 
> Maybe I'm peculiar but I always find it absolutely, totally jaw-dropping
> when people use text *editors* to *look* at file content.  Makes my toes
> curl up and blood curdle.
> 
> Why on earth would you want to edit your system logs anyway?
> 
> On De{bi,vu}an derivatives, I'd use `pager`.  On any other Unix-based
> OS, I'd use `more` or `less`, preferably.
> 
> # On my own machines `lv` makes a fine `pager` for me.  On the fly
> # decompression and handling of many different encodings.  So for me,
> # it's just
> #
> #  pager /var/log/syslog.2.gz
> #
> # without any `zmore` or `zcat` piping.  There is still no zpager :-/
> # but with `lv` I don't really need one.
> 
> Hope this helps,
> --
> Olaf Meeuwissen, LPIC-2FSF Associate Member since 2004-01-27
>  GnuPG key: F84A2DD9/B3C0 2F47 EA19 64F4 9F13  F43E B8A4 A88A F84A 2DD9
>  Support Free Softwarehttps://my.fsf.org/donate
>  Join the Free Software Foundation  https://my.fsf.org/join
> ___
> Dng mailing list
> Dng@lists.dyne.org
> https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] Viewing file content (was Re: system administration of non-systemd distros and releases)

2021-11-26 Thread marc
> > What could possibly be easier than vim /var/log/messages, or
> > vi /var/log/messages, or emacs /var/log/messages, or
> > nano /var/log/messages? And notice with the old way, you have a choice,
> > rather than having to look at log output with the vendor's proprietary
> > tool.
> 
> Maybe I'm peculiar but I always find it absolutely, totally jaw-dropping
> when people use text *editors* to *look* at file content.  Makes my toes
> curl up and blood curdle.
> 
> Why on earth would you want to edit your system logs anyway?
> 
> On De{bi,vu}an derivatives, I'd use `pager`.  On any other Unix-based
> OS, I'd use `more` or `less`, preferably.

I concur - the model ought to be that log files aren't writeable
in the conventional sense, but append only. For installations where
one worries about security this might even be enforced with chattr
at the filesystem level (ie not just convention).

Using a pager is also more efficient - pagers are simpler, faster and 
don't risk accidentally modifying the file. Depending on 
editor a harmless update can involve a rename() aka mv, in which case 
subsequent log entries might be lost. 

If (any of) you still prefer to use an editor, consider invoking it in 
read-only mode. Eg "vim" can also be invoked as "view"

regards

marc
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng