Re: [SLUG] Conversion question

From: Chuck Hast (wchast@gmail.com)
Date: Wed Jan 17 2007 - 14:55:11 EST


On 1/17/07, Paul M Foster <paulf@quillandmouse.com> wrote:
> Chuck Hast wrote:
> > I am dealing with that old buggaboo, the end of line conventions which for
> > unix type systems is the 0x0A or LF. For dos/win it is 0x0D or the CR.
> >
> > If I was just converting the file for dos/win use I would just run it
> > through
> > unix2dos and let it dump it into a new file with the proper format. But in
> > this case I have a small script that reads a file out to the screen, so
> > what
> > I need to do is the conversion and have the result dumped to the screen,
> > here is a sample of one, it reads the file from one of the files in proc.
> >
> > #!/bin/bash
> > #
> > while : ; do
> > cat /proc/net/rose_neigh
> > sleep 1
> > clear
> > done
> >
> > This is the output:
> > addr callsign dev count use mode restart t0 tf digipeaters
> > 00043 KC5QCN-9 sp0 10 0 DTE no 0 0
> > 00042 KD4YAL-9 ax0 1 1 DTE yes 0 0
> > 00041 W4MIN-9 ax0 1 0 DTE no 0 0
> > 00040 N3PPC-9 ax0 2 0 DCE yes 0 0
> > 00039 N4PLZ-9 ax0 8 1 DCE yes 0 0
> > 00038 F5KBW-9 ax0 9 1 DTE yes 0 0
> > 00037 F6BVP-11 ax0 12 0 DTE yes 0 0
> > 00036 VK2TV-2 ax0 1 1 DCE yes 0 0
> > 00032 K4GBB-9 ax0 12 1 DTE yes 0 0
> > 00001 RSLOOP-0 ??? 5 0 DCE yes 0 0
> >
> > This is the output if viewed on a win machine:
> >
> > addr callsign dev count use mode restart t0 tf digipeaters
> > 00043 KC5QCN-9 sp0 10 0 DTE no 0 0
> >
> > 00042 KD4YAL-9 ax0 1 1 DTE yes 0 0
> > 00041 W4MIN-9 ax0 1 0 DTE no 0 0
> >
> > 00040 N3PPC-9 ax0 2 0 DCE yes 0 0
> > 00039 N4PLZ-9 ax0 8 1 DCE yes
> > 0 0
> > So I need to add unix2dos or a sed statement that will intercept the
> > file and
> > do the conversion and then output it to the screen.
> >
> > I am way down at the bottom when it comes to scripts as you can see. I
> > bet there is a better way to even do that script, but little by little.
> >
>
> For clarification:
>
> Line endings in Unix/Linux: LF (0x0a)
> Line endings in DOS/Windows: CR/LF (0x0d 0x0a)
> Line endings in Mac: CR (0x0d)
>
> Not quite sure why you're using a script. Just do:
>
> cat filename | dos2unix
>
> You could put that in a script, if you like. The output will be to
> screen, with line endings of CR/LF.
>
>

In the linux switch the user interface just calls a command which does
exaxtly that. The little script causes the file dump to repeat every second
or whatever time the user wants to set in the sleep. These little scripts
are used to monitor changes in the files they are dumping, what I do is
ssh into the switch in question and then call the script, it starts dumping
that data to my screen, and then from another machine or screen I issue
a command to the switch and watch to see what happens in the file in
question. These files are actually data in /proc so they change as circuits
are set up or applications called on the linux switch.

Just a little background we are in the process of changing the amateur
radio packet switches over to Linux, the next step will be to add higher
speed links. These are just small tools that we have done to make the
work and setting up of these devices easier.

-- 
Chuck Hast  -- KP4DJT --
To paraphrase my flight instructor;
"the only dumb question is the one you DID NOT ask resulting in my going
out and having to identify your bits and pieces in the midst of torn
and twisted metal."
-----------------------------------------------------------------------
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:37:30 EDT