[Lilug] Quick question about find tar, and netcat

Matt Surico surico at buoy.com
Sun Feb 22 21:08:43 PST 2009


~ ~ wrote:
> I'm attempting to salvage some media files from a laptop that had
> windows running on it. I've booted a livecd an I've connected another
> laptop to dump to via firewire (works pretty awesome with eth1394) so
> I'm  using netcat for speed (over 10gb of media) . I want to do
> something along the lines of:
> find . -name \*.mp3 -exec tar cfv - '{}' | netcat hostip 1234
> receiving machine is doing :
> netcat -l -p 1234 > Mp3.tar
> but it's not working, mainly I think because I'm attempting to just
> create with one file as oppossed to append them to the archive. so
> I've tried tar with -r or -A but still no dice. What am I doing wrong
> here?
Right - you'll only get one file with the above.  You'll also find that
you can't use tar in append mode when trying to write to stdout with "-".

I tested the following on the source (sending) side (keep the receiving
end the same) and it seemed to work:

tar cvf - `find . -name "*.mp3"` | netcat hostip 1234

The only downside I found was that the above command didn't
auto-terminate when the find completed.  I guess you can monitor the
Mp3.tar file on the receiving end and when you see activity has
completed, you might terminate the sending side.

Another less elegant alternative (but safer) is to run the find command
and direct stdout to a file, then use that file as the -T option....

find . -name "*.mp3" > myfiles.txt
tar cvf - -T myfiles.txt | netcat hostip 1234
(I tested this and found the tar command didn't terminate either, but at
least you have your file list to compare to).

HTH

Matt S
LILUG Secretary




More information about the Lilug mailing list