File Packing Ideas

I am testing the CGI solution now, and it may do the trick. Better would
even be bzipped data.

I essentially get one shot to pass a complete file to a remote socket
connection, and want to do it in the neatest, most reliable, and even
smallest, fashion.

All ideas will be considered :slight_smile: As I said I tried various pack, gsub,
Marshall ways, but am not totally satisfied yet.

Thanks for answering.
bubba_joe_louis@yahoo.com

···

-----Original Message-----
From: Michael Campbell [mailto:michael_s_campbell@yahoo.com]
Sent: Tuesday, November 12, 2002 1:15 PM
To: ruby-talk@ruby-lang.org
Subject: Re: File Packing Ideas

I may have misread the original problem description, but did you not
say “…convert it into a single line string with no characters
readable in it, (such as \n, \t, etc.) …” ?

Did you mean you need unprintables converted, or that you wanted to
end up with a string such that no characters in it are “readable”?

The solution given is for the first one, but normal printable chars
are left untouched with CGI; is this what you wanted?

— “Vera, Michael” mxvera@qwest.com wrote:

Your answer is cool; and by cool, I mean totally sweet.

Thank you!

-----Original Message-----
From: Nikodemus Siivola [mailto:tsiivola@cc.hut.fi]
Sent: Tuesday, November 12, 2002 12:15 PM
To: ruby-talk@ruby-lang.org
Subject: Re: File Packing Ideas

On Wed, 13 Nov 2002, Vera, Michael wrote:

I am looking for help to solve this problem I have. I need to
read in a
file, and convert it into a single line string with no characters
readable
in it, (such as \n, \t, etc.) so that it can be sent over a
socket
connection and reconverted on the other side.

The CGI class solves this problem for you: URL’s need to be escaped
as
well.

irb(main):001:0> require ‘cgi’
true
irb(main):002:0> str = “\n\f\r\b”
“\n\f\r\010”
irb(main):003:0> str2 = CGI.escape str
“%0A%0C%0D%08”
irb(main):004:0> str == CGI.unescape(str2)
true
irb(main):005:0>

– Nikodemus

=====

Yahoo IM: michael_s_campbell


Do you Yahoo!?
U2 on LAUNCH - Exclusive greatest hits videos
http://launch.yahoo.com/u2

How about open, write, close? TCP sockets are 8-bit clean.

"Cleaner" (in the sense of more standardised, better control, ability to do
authentication etc) would be to use a HTTP POST. The far end could then be
just a webserver.

If you want the semantics of a "file transfer" then you could use FTP.

There are built-in Ruby libraries for HTTP and FTP.

Regards,

Brian.

···

On Wed, Nov 13, 2002 at 04:23:15AM +0900, Vera, Michael wrote:

I am testing the CGI solution now, and it may do the trick. Better would
even be bzipped data.

I essentially get one shot to pass a complete file to a remote socket
connection, and want to do it in the neatest, most reliable, and even
smallest, fashion.

All ideas will be considered :slight_smile: As I said I tried various pack, gsub,
Marshall ways, but am not totally satisfied yet.