Unix Technical Forum

FTP PROBLEM with ^M

This is a discussion on FTP PROBLEM with ^M within the AIX Operating System forums, part of the Unix Operating Systems category; --> When I ftp from my pc to a unix box, my file fransfers, but each line contains a ^M ...


Go Back   Unix Technical Forum > Unix Operating Systems > AIX Operating System

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-04-2008, 10:07 PM
Pete Rau
 
Posts: n/a
Default FTP PROBLEM with ^M

When I ftp from my pc to a unix box, my file fransfers, but each line
contains a ^M at the end of the line. Does anyone know how to remove the
character.

Thanks.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-04-2008, 10:07 PM
Mike Klein
 
Posts: n/a
Default Re: FTP PROBLEM with ^M

In article <3fdde604_1@news.athenanews.com>,
"Pete Rau" <Pete_Rau@beamspeed.net> wrote:

> When I ftp from my pc to a unix box, my file fransfers, but each line
> contains a ^M at the end of the line. Does anyone know how to remove the
> character.
>
> Thanks.
>
>


A quick and dirty way is to use tr:

tr '\r' '\n' <oldfile >newfile
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-04-2008, 10:07 PM
Gary R. Hook
 
Posts: n/a
Default Re: FTP PROBLEM with ^M

Pete Rau wrote:

> When I ftp from my pc to a unix box, my file fransfers, but each line
> contains a ^M at the end of the line. Does anyone know how to remove the
> character.


Use the "ascii" subcommand in ftp to set your file mode
to ASCII. Or otherwise force the mode to ASCII instead
of binary. ASCII mode will cause the two machines to
do what's necessary for <CR><LF> pairs when going from
a windoze box to Unix.

Once there, the tr command is helpful (as suggested in another
reply).

--
Gary R. Hook / AIX PartnerWorld for Developers / These opinions are MINE
__________________________________________________ ______________________

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 01-04-2008, 10:07 PM
Steve Nottingham
 
Posts: n/a
Default Re: FTP PROBLEM with ^M

"Pete Rau" <Pete_Rau@beamspeed.net> wrote in message news:<3fdde604_1@news.athenanews.com>...
> When I ftp from my pc to a unix box, my file fransfers, but each line
> contains a ^M at the end of the line. Does anyone know how to remove the
> character.
>
> Thanks.


vi the file and do :1,$s/<ctrl v><ctrl m>//g then do :wq!
I think you also need to ftp the file using ascii mode, butI can't confirm this.

Steve
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 01-04-2008, 10:07 PM
Chris Cox
 
Posts: n/a
Default Re: FTP PROBLEM with ^M

Pete Rau wrote:
> When I ftp from my pc to a unix box, my file fransfers, but each line
> contains a ^M at the end of the line. Does anyone know how to remove the
> character.
>
> Thanks.
>
>


After the fact, you can use vi interactively
with :%s/.$//
(as long as there's carriage return after the last line.. you
may want to check that.. otherwise you may drop the last
character of the file)

Or use perl:

perl -pi -e 's/.$//' filename

Make sure you are in ascii mode when you transfer text files...
if you are transferring a mix of files... then you can
use the perl command above to fix the text ones.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:40 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com