Hi All,

Currently I'm utilising Net::SSH2 perl script to sftp file from Windows to Unix server. However, after transering the file, the file is having an extra character (^M) at the end of each line as the sample below.

0146669944 502126920956715 1^M 0146456870 502124950748150 1^M 0142811862 502122912649310 1^M

Is this due to the file format that's being transferred is in binary format and not in ASCII? If this is the case how do i incorporate the change of the file type from binary to ascii within the script below?

use warnings; use strict; use Net::SSH2; my $datafile = "D:/ETL/RPT/MD/IMSI_SICAP.lst"; my $ssh2 = Net::SSH2->new; $ssh2 -> connect("192.100.100.238") or die ("Error"); $ssh2 -> auth(username => 'user', password => 'aaa') or die ("Error"); $ssh2 -> blocking(1); $ssh2 -> scp_put("${datafile}IMSI_SICAP.lst","/timesten/IMSI_SICAP.lst +")or die ("Error"); $ssh2 -> disconnect();

Would really appreciate some guidance on this. Thanks.


In reply to Convert binary to ascii while sftp using Net::SSH2 by tsandras

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.