Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 4 Nov 2001 22:16:42 -0500
From:      Brian T.Schellenberger <bts@babbleon.org>
To:        "David Loszewski" <stealth215@mediaone.net>, <freebsd-questions@FreeBSD.ORG>
Subject:   Re: ^M on end of lines
Message-ID:  <01110422164202.03811@i8k.babbleon.org>
In-Reply-To: <000e01c164e9$4592a300$3000a8c0@sickness>
References:  <000e01c164e9$4592a300$3000a8c0@sickness>

next in thread | previous in thread | raw e-mail | index | archive | help

--------------Boundary-00=_U35BVOVH4E4Q14FMILBN
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: 8bit

On Saturday 03 November 2001 23:29, David Loszewski wrote:
> So then how do I strip it of the '^M's then? Lol, this is the biggest
> pain in the ass, and I'm not a complete newbie. 

I'm still trying to get what's different or surprising about this--nothing 
should be any different w/r/t FreeBSD & ^M vs. any other Unix-like O/S.
If something *is* different, you must be using a different editor or capture 
process or *something* than what you used before.

> If I do 'wget' I get the
> same thing sometimes so I'm starting to think that there's something
> wrong with the configs in the system.  Ideas on where I should start
> looking?

I've attached the scripts that I actually use to do this.  Just put both of 
them in a directory that's in your path & you're all set.  I've tossed "all" 
in for good measure; you can use

unmsdos *.* 

to make all of the files "Unixy" or 

all '*.*' 'uncrnl $i'

to just un-cr-nl them.

I'm sure that there are standard utilities to do this, but this is literaly 
what I do.


>
> Dave
>
> -----Original Message-----
> From: Ryan Thompson [mailto:ryan@sasknow.com]
> Sent: Saturday, November 03, 2001 12:54 PM
> To: Brian T.Schellenberger
> Cc: David Loszewski; freebsd-questions@FreeBSD.ORG
> Subject: Re: ^M on end of lines
>
> Brian T.Schellenberger wrote to David Loszewski:
> > On Friday 02 November 2001 19:59, you wrote:
> > > Maybe the question I should be asking instead is, is it normal to
>
> see a
>
> > > crap load of '^M's in a file in FreeBSD?
> >
> > Never happens to me (except with MS-DOS files, and of course that
>
> happens in
>
> > Linux as well).  So something is configured in a screwy way on our
>
> system if
>
> > it's any different from Linux.
> >
> > But here's the deal on FTP, as I understand it:
> >
> > in text mode, FTP uses the MS-DOS conventions (it adds ^Ms), so if you
> > run FTP on Linux in text (ascii) mode but the FTP on FreeBSD in binary
> > mode, then Linux will add the ^Ms and FreeBSD won't strip 'em.
>
> Not the case.. Unless maybe your FTP is broken?
>
> > If you are running *nix-to-*nix, then FTP in binary mode on both ends;
> > if it's a text file you can use text mode on both ends.  Sounds like
> > somehow the FTPs aren't communicating and they are in different modes.
> >
> > Of course that's not supposed to be possible, and I've never seen it,
> > but it sounds like what might be happenening to you anyway.
>
> Actually, what ASCII mode is supposed to do, is, when transferring text
> files, convert to the platform specific text format. (Which really means
> the receiver strips or adds the ^M). This instruction is actually in our
> training manual for new employees developing code on Windows machines
> who
> need to transfer via FTP. USE ASCII MODE FOR ASCII FILES. :-)
>
> - Ryan
>
> > > Dave
> > >
> > >
> > > -----Original Message-----
> > > From: owner-freebsd-questions@FreeBSD.ORG
> > > [mailto:owner-freebsd-questions@FreeBSD.ORG] On Behalf Of undergra
> > > Sent: Friday, November 02, 2001 7:28 PM
> > > To: Andreas Ntaflos; David Loszewski
> > > Cc: freebsd-questions@FreeBSD.ORG
> > > Subject: RE: ^M on end of lines
> > >
> > > tr -d "\015" < input-file > output-file
> > > ----- Mensaje original -----
> > > De: "Andreas Ntaflos" <ntaflos.andreas@gmx.net>
> > > Para: "David Loszewski" <stealth215@mediaone.net>
> > > CC: <freebsd-questions@FreeBSD.ORG>
> > > Enviado: sábado, 03 de noviembre de 2001 0:44
> > > Asunto: Re: ^M on end of lines
> > >
> > > > On Fri, Nov 02, 2001 at 05:43:18PM -0500, David Loszewski wrote:
> > > > > Yea, but then I have to do that to all the files
> > > > > Not pretty when you have a 100 files
> > > > >
> > > > > Dave
> > > > >
> > > > >> a simple fix after dl is to open it up in vi and do
> > > > >>
> > > > >> :%s,^V^M,,g
> > > > >>
> > > > >> -r
> > > >
> > > > The following perl command issued on the CLI will get
> > > > rid of these annoying ^Ms.
> > > >
> > > > # perl -e -i -p 's/\r\n/\n/s' filename
> > > >
> > > > you can use wildcards too.
> > > >
> > > > There are also ports to solve these problems, like dos2unix.
> > > >
> > > > regards
> > > > --
> > > > Andreas "ant" Ntaflos
> > > > ntaflos.andreas@gmx.net
> > > > Vienna, AUSTRIA
> > > >
> > > > To Unsubscribe: send mail to majordomo@FreeBSD.org
> > > > with "unsubscribe freebsd-questions" in the body of the message
> > >
> > > To Unsubscribe: send mail to majordomo@FreeBSD.org
> > > with "unsubscribe freebsd-questions" in the body of the message
> > >
> > >
> > > To Unsubscribe: send mail to majordomo@FreeBSD.org
> > > with "unsubscribe freebsd-questions" in the body of the message

-- 
Brian T. Schellenberger . . . . . . .   bts@wnt.sas.com (work)
Brian, the man from Babble-On . . . .   bts@babbleon.org (personal)
                                        http://www.babbleon.org

-------> Free Dmitry Sklyarov!  (let him go home)  <-----------

http://www.eff.org                 http://www.programming-freedom.org 

--------------Boundary-00=_U35BVOVH4E4Q14FMILBN
Content-Type: application/x-perl;
  charset="iso-8859-1";
  name="unmsdos"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="unmsdos"

IyEgL3Vzci9iaW4vcGVybAoKaWYgKCRBUkdWWzBdIGVxICctYycpICAgIyBTcGVjaWFsIENELVJP
TSBtb2RlCnsKICAgICRjZHJvbSA9IDE7Cn0KCmlmICgkQVJHVlswXSBlcSAnLW4nKSAKewogICAg
c2hpZnQ7CiAgICAkcHV0bmFtZSA9IDE7Cn0KCmZvcmVhY2ggKEBBUkdWKQp7CiAgICAjIHVubXNk
b3MgYWNjcGV0cyBhICJxdW90aW5nIiBjb252ZW50aW9uIG9mIGFuZ2xlLWJyYWNrZXRzIHRvCiAg
ICAjIHF1b3RlIG5hbWVzLiAgSWYgaXQgaGFzICdlbSwgc3RyaXAgJ2VtLiAgSWYgaXQgaGFzIHRo
ZSBsZWFkaW5nLAogICAgIyBidXQgbm90IHRoZSB0cmFpbGluZywgYnJhY2tldCB0aGVuIHNhdmUg
dGhpcyBvbmUgYW5kIGNvbWUgCiAgICAjIGFyb3VuZCBhZ2Fpbi4gIEZpcnN0IHNlZSBpZiB3ZSBh
cmUgY29udGludWVkIGZyb20gYmVmb3JlLgoKICAgIGlmICgkcGVuZGluZykKICAgIHsKICAgICAg
ICAkXyA9ICRwZW5kaW5nIC4gJyAnIC4kXzsKICAgICAgICAkcGVuZGluZyA9ICIiOwogICAgfQoK
ICAgIGlmICgvXjwvKQogICAgewogICAgICAgIGlmICgvPiQvKQogICAgICAgIHsKICAgICAgICAg
ICAgcy9ePC8vOwogICAgICAgICAgICBzLz4kLy87CiAgICAgICAgfQogICAgICAgIGVsc2UKICAg
ICAgICB7CiAgICAgICAgICAgICRwZW5kaW5nID0gJF87CiAgICAgICAgICAgIG5leHQ7CiAgICAg
ICAgfQogICAgfQoKICAgICRwYXRoID0gJF87CiAgICAkcGF0aCA9ICIuIiAgaWYgKCEgL1wvLyk7
CiAgICAkcGF0aCA9fiBzfC9bXi9dKiR8fDsKICAgIHN8Xi4qL3x8OwogICAgJG5ld25hbWUgPSAk
XzsKCiAgICBpZiAoJGNkcm9tKQogICAgewogICAgICAgIG5leHQgaWYgKGxlbmd0aCA+IDEyIHx8
IC9bYS16XS8pOyAgIyAxMiA9IDguMyAoMTIzNDU2NzguQUJDKQogICAgICAgIGdvdG8ganVzdExv
d2VyY2FzZTsKICAgIH0KCiAgICAjIElmIGl0J3Mgb25lIG9mIG15ICJyYXRlZCIgbmFtZXMsIHNl
cGVyYXRlIG91dCB0aGUgcmF0aW5nIHBhcnQuCiAgICAjIEFsd2F5cyB0YWtlIG91dCBsZWFkaW5n
IHBhdGhzIGZvciBmaWxlIHJlbmFtZXMuCgogICAgJHByZWZpeCA9ICIiOwogICAgaWYgKC9eKC4q
XC8pPyhcdystXHcrLVx3KzopPy8pCiAgICB7CiAgICAgICAgJHByZWZpeCA9ICQmOwogICAgICAg
ICRfID0gJCc7CiAgICB9CgogICAgIyBuYW1lIGNvbnZlcnNpb25zLgogICAgJG5ld25hbWUg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AgZWxzZQogICAgICAgIHsKICAgICAgICAgICAg
aWYgKHJlbmFtZSgkcHJlZml4IC4gJF8sICRwcmVmaXggLiAkbmV3bmFtZSkpCiAgICAgICAgICAg
IHsKICAgICAgICAgICAgICAgICRfID0gJG5ld25hbWU7CiAgICAgICAgICAgIH0KICAgICAgICAg
ICAgZWxzZQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBwcmludCBTVERFUlIgIlJlbmFt
ZSB0byAkbmV3bmFtZSBmYWlsZWQuXG4iOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQoK
ICAgICMgQ2hhbmdlcyB0byBmaWxlIGNvbnRlbnRzIC4gLiAuCiAgICAkXyA9ICRwcmVmaXggLiAk
XzsKICAgIGlmICgtVCAkXyAmJiAhJGNkcm9tKQogICAgewogICAgICAgIGlmIChzeXN0ZW0oJ3Vu
Y3JubCcsICRfKS8yNTYgPT0gMCkKICAgICAgICB7CiAgICAgICAgICAgIHByaW50ICJVbmNybmwn
ZWQgJF9cbiI7CiAgICAgICAgfQogICAgICAgIGVsc2UKICAgICAgICB7CiAgICAgICAgICAgIHBy
aW50IFNUREVSUiAiVW5jcm5sICRfIGZhaWxlZC5cbiI7CiAgICAgICAgfQogICAgfQp9Cgo=

--------------Boundary-00=_U35BVOVH4E4Q14FMILBN
Content-Type: application/x-shellscript;
  charset="iso-8859-1";
  name="uncrnl"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="uncrnl"

IyEgL2Jpbi90Y3NoIC1mCiMgc2V0IGVjaG8KCmlmICgiJDEiID1+ICovKikgdGhlbgogICAgc2V0
IHBsYyA9ICQxOmgKICAgIHNldCBmaWxlID0gJDE6dAogICAgY2QgJHBsYwplbHNlCiAgICBzZXQg
ZmlsZSA9ICQxCmVuZGlmCgptdiAkZmlsZSB9JGZpbGV9CnRyIDwgfSRmaWxlfSA+ICRmaWxlIC1k
ICdccicK

--------------Boundary-00=_U35BVOVH4E4Q14FMILBN
Content-Type: application/x-shellscript;
  charset="iso-8859-1";
  name="all"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="all"

IyEgL2Jpbi90Y3NoIC1mCiMgc2V0IGVjaG8KCnNldCBzaWxlbnQgPSAwCmlmICgiJDEiID09ICIt
cyIpIHRoZW4KICAgIHNldCBzaWxlbnQgPSAxCiAgICBzaGlmdAplbmRpZgoKaWYgKCIkMSIgPT0g
Ii1tIikgdGhlbgogICAgc2hpZnQKZWxzZQogICAgc2V0IG5vbm9tYXRjaAplbmRpZgpzZXQgcHJv
bXB0ID0gIj4gIgpzb3VyY2Ugfi8uY3NocmMKCnNldGVudiBTICckJwoKc2V0IGNtZCA9IGBlY2hv
ICQyIHwgc2VkICJzL0AvJFMvImAKCmZvcmVhY2ggaSAoJDEpCiAgICBlY2hvICcgJwogICAgZWNo
byAnPj4+JyAkaSAnPDw8JwogICAgaWYgKCEgJHNpbGVudCkgXAogICAgICAgIGV2YWwgZWNobyBp
PSRpIDogIiRjbWQiIAogICAgZXZhbCAkY21kCmVuZAoKZWNobyAnICcKCg==

--------------Boundary-00=_U35BVOVH4E4Q14FMILBN--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?01110422164202.03811>