If the telnet protocol is all you can use than about the only way I can suggest is to use uuencode
on the source side to output the file as regular text to standard output.
Then have your terminal emulator capture the output to a file and use uudecode
on your local box to decode it.
The advantage of this is that uudecode
is well used to removing cruft from around the outside of encoded documents.
Transcript follows:
pax$ cat qq.c | uuencode qq.c
begin 644 qq.c
m(venxvqux&x@/x-tx&ex+f@^xb-i;f-l=xxe(xqt:xue+f@^xfen=x!mxxen
m*xd@>ph@(xx@:xyt(&d[xbx@(x!t:xuexwx@>xl*(xx@(xxr.ph@(xx@xf]r
m(xai(xt@,xl@:xx\(x$p,xxp,xxp.r!i*rlixbx@(xx@(xx@>xx](&=e=&xa
h=&x@*x(r,x$q,xxq,x$p,c@p,x(i.ph@(xx@<fxt=x)n(xx[xgt*x@xx
x
end
pax$ ( echo carp ; cat qq.c | uuencode newqq.c ; echo more carp ) | uudecode
pax$ diff qq.c newqq.c
pax$ _
You can see that the file is successfully extracted even with the presence of a certain type of fish (I didn't want to take the chance of offending anyone) in the output stream - uudecode
safely ignores this since it's not relevant to the file.