• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Remove ^M character in text file

 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I sftp (secure FTP) some text files from unix box to another unix box using the JSCH API. When the same file is FTPed I don't see the ^M character but the SFTped file has a ^M characters at the end of each line of the file. I cannot use any utility to remove the ^M characters. Is there any settings that I can do in the Unix box to solve this or is there any settings in the JSCH API to solve this.

Any help on this is very much appreciated.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
FTP has a setting to transfer files in binary mode instead of ASCII mode; that should prevent any changes from happening.
 
Rancher
Posts: 4803
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perhaps Ulf has it backwards? If you send it binary, it is send as is. If yo used it as text, it allows line conversions.

Many SFTP implementations don't have modes like ftp did. And since OP talks about using an API, what is supported depends on the API.

If you can't use something nice, like dos2unix, you can always just chop off the ^M at the end of lines after you use a readline() to get the string.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic