[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: uudecode files with multiple encoded files



On Wed, Jul 04, 2001 at 12:44:38PM -0700, Aaron Brashears wrote:
> I have a few files that contain multiple uuencoded files inside of
> them. As it stands uudecode will only decode the first one in the
> file, so I load up the file in an editor and delete the first encoded
> file, and uudecode the larger file again to extract the next uuencoded
> file. This is a pain. 
> 
> I searched for a good method to do this, but was unable to find
> anything useful. It occurs to me that it might work to use something
> like sed that can have multiple output files, but I don't know of any
> utilities that do this.
> 
> Any advice to save time on the edit, uudecode, edit, uudecode cycle?
> 
Disclamer: Any code in this message was never tested. Fix bugs yourself or mail me with errors.

IMHO perl would be a more suitable solution. Here is how I would do it.
Make a perl script that does the following

#!/usr/bin/perl 

sub decode()
{
$str = shift; # get the file we have collected
open PIPE, '| uudecode'; open pipe to uudecode program
print PIPE $str; # send the file down the pipe
close PIPE; # close pipe
}

while (<STDIN>) # while standard input is going
{
$file = $file + $_; # add another line to the buffer
if /end/ { decode($file); $file = ""; } # if we are at the end of the file decode 
}

Any other scripting language should let you do the same trick, sed by itself will not help
only with some shell scripting ( same shit as the above ) awk might be a good choice

-- 
In earlier days, virgins were often selected to beta test volcanos.



Reply to: