Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Convert binary to ascii while sftp using Net::SSH2

by 0xbeef (Hermit)
on Mar 01, 2011 at 20:34 UTC ( #890812=note: print w/replies, xml ) Need Help??


in reply to Convert binary to ascii while sftp using Net::SSH2

The problem is that you are transferring a text file between systems that differ in how they represent an end of line character. This is precisely the reason why a program such as FTP implement the bin and ascii mode functions.

When you transfer a file in binary mode, it remains unchanged (this mode is typically used to transfer compiled programs / BINaries).

When dealing with end of line characters in text files that roboticus elaborated on, ascii mode would have to be used to do a transformation of the end of line character to make it appropriate to the target platform. In perl, you would need to use a s/\r\n/\n/; to do the equivalent transform when doing a Windows -> UNIX transfer.

The reason for this madness lies in how early computer systems had to interact with teletype and typewriter devices that were unable to advance the print head to the next line in single character time (see Newline).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://890812]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2022-05-16 17:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (63 votes). Check out past polls.

    Notices?