From: Fengfeng Li Date: 2012-03-29T11:42:56+09:00 Subject: Re: How to process telnet data(binary) Brian Candler wrote in post #1053836: > Have you tried setting Binmode option to Net::Telnet? > > # Binmode:: if false (the default), newline substitution is > performed. > # Outgoing LF is > # converted to CRLF, and incoming CRLF is converted to LF. > If > # true, this substitution is not performed. This value > can > # also be set with the #binmode() method. The > # outgoing conversion only applies to the #puts() and > #print() > # methods, not the #write() method. The precise nature of > # the newline conversion is also affected by the telnet > options > # SGA and BIN. > > However I would say that your proposed way of doing things is very > fragile, because if nothing else there will be trailing garbage (the > command prompt) added to your data. > > You might want to look at SCP or SFTP for a more robust way of copying > files from a Linux system. Thanks for your reply:) I've already gsub the prompt. I tried Binmode true, the result is it will change \n to \r\n, besides, same problem exist. For example, "\xFF" is changed into "\xFF\xFF". I will look into SCP/SFTP and see if there's a better way. -- Posted via http://www.ruby-forum.com/.