Hey Perl Guys and Gals, I have an issue that I need some assistance with (even just a push in the right direction should be enough). Note, these are actually in a small perl module and I do use strict and warnings, they just aren't present in my example here.
I've got a simple backup routine that looks like the following (Just assume the ssh works, I know that part is good but I've changed the IP and stripped out some extra command line flags that contained sensitive information): @in = ssh("1.1.1.1", "tar cf - /home/$user | gzip") open(TEMP, ">/tmp/$user.tar.gz") or die "Blargh!"; print TEMP @in; close(TEMP); Now this does exactly what I want it to do... I end up with a valid tar.gz file in /tmp however I suddenly realized that this has one huge problem, the entire 'tarball' is held in memory in @in before it's written to disk. That's my hangup right there, I may have a 200Mb home directory being backed up and I can't have that all residing in memory until the print. I tried the following, and I'm pretty sure it's not working because sysread expects to read from a filehandle. I can see the ssh running, the tar spits it's typical "tar: Removing leading '/' from member names" to STDERR but nothing gets written to disk (I end up with an empty file). Like I said, I'm pretty sure it's because I'm trying to sysread from something other than a filehandler. open(TEMP, ">/tmp/$user.tar.gz") or die "Blargh!"; while (sysread(ssh("1.1.1.1", "tar cf - /home/$user | gzip"), $buf, 1024)) { syswrite(TEMP, $buf, 1024); } close(TEMP); Okay, I just tried something and I need some opinions... does this accomplish what I'm trying to accomplish (I want it to go straight to disk and not reside in memory longer than it needs to): print TEMP ssh("1.1.1.1", "tar cf - /home/$user | gzip"); Now, I have a feeling it should be pretty obvious what I'm trying to accomplish, I just don't know if I'm actually getting it done with the above. I tried using Net::SSH::Perl to read it's input off the buffer as it came in however we had issues with it 'missing' some of the input unless we implemented arbitrary slowdowns in the data being returned (if anyone knows how to get around that I can easily use that as a solution since it lets you process it like a stream of data). Thanks, Tim -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>