Re: [SLUG] Conversion question

From: Eben King (eben01@verizon.net)
Date: Thu Jan 18 2007 - 17:16:47 EST


On Thu, 18 Jan 2007, Chuck Hast wrote:

> What we have is data coming out of some files in proc, this data changes
> constantly depending on the data links and what the timers are doing. What
> we are doing is in one case when a certain command is called from the
> switch interface, capturing a snapshot of that data and dumping it to the
> requesiting user. In some cases we need to see it in dos format and in others
> with just a CR on the end.

Mac format? Really?

In a script I'd do it like so:

LINE_STYLE=DOS # Mac, DOS, or Linux
                # set this differently for each user

case $LINE_STYLE in
     Mac)
         FIXER="tr '\\n' '\\r' ;;
     Linux)
         FIXER=cat ;;
     DOS)
         FIXER=unix2dos
esac

$FIXER < /proc/whatever > userfile
# or just dump to stdout if that's what you want
# "$FIXER <" only works if $FIXER is always a single command

> I thought we only needed to see the dos format
> for those people who are using windows, but turns out there are times when
> we need to see the line ended with a CR, and it appears that good old Linux
> pretty well handles whatever is tossed at it, too bad some others do not...

Well, vim does. Mac-style files get each line overprinted on a console
with "cat" so you only see the last line there.

> I will test more of this until I get the answer I am looking for, thanks
> for the work with the dos format, that is working great, now just to clear
> up the last one with the NL ending in a CR only... Then I will have the
> whole mess covered.

-- 
-eben    QebWenE01R@vTerYizUonI.nOetP    http://royalty.no-ip.org:81
SCORPIO:  Get ready for an unexpected trip when you fall screaming
from an open window.  Work a little harder on improving your low self
esteem, you stupid freak.  -- Weird Al, _Your Horoscope for Today_
-----------------------------------------------------------------------
This list is provided as an unmoderated internet service by Networked
Knowledge Systems (NKS).  Views and opinions expressed in messages
posted are those of the author and do not necessarily reflect the
official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 20:41:27 EDT